SQL abstraction/generalization/protection layer.
Current connectors available:
- MySql
- MsSql
- Postgre (not tested too much)
- OleDb (requires .NET Framework).
This library allows you fluent SQL building, even for very complex queries.
It has a built-in capability of reading/writing records from classes - in a very different way than in Entity Framework.
It it less automated, which means you have to have your record class inherit from AbstractRecord
and supply the definition of the schema.
But - that very definition of the schema allows to manage the whole database lifecycle from the code, including creating from scratch, migrations etc.
It also allows matching value types according to the schema when applicable.
The magic happens in the little SchemaGenerator
addon for Visual Studio.
This little guys takes a "pseudo-script" and converts it to a full code of an AbstractRecord
record.
You can override/extend almost anything in there, either in the script itself, or by defining a partial class
and adding stuff.
This used to be dg.Sql
library, renamed to SequelNet
.
Migration notes - in the Releases section, for 2.0.0
.
The use is pretty straight-forward. To supply a default connector, add a SequelNet.Connector key in the appSettings of web.config. Like this:
<add key="SequelNet.Connector" value="MySql" />
To supply a default connection string, add a SequelNet
connection string in web.config
,
or SequelNet::ConnectionString
key in app config.
Another option is to add a SequelNet::ConnectionStringKey
key in the app config, which specifies the connectionString's name to be used.
Query
: Build the query, and executes in a number of different ways, and different way to retrieve the resultsConnectorBase
is the base class for the connector layer. Each connector has a subclass of this class, which supplies the basic functionalities, similar to theSqlConnection
class. (I am considering a change this class's name in the future...)DataReaderBase
is the same story as withConnectorBase
, providing the same functionality asSqlDataReader
AbstractRecord
is a DAL class that represents your data, and contains aTableSchema
, data accessors, and helper functions. UsingAbstractRecord
is completely optional!TableSchema
is a class representing the an actual db schema. This assists theQuery
in converting values where necessary, bulding queries or even buildingCREATE TABLE
,ALTER TABLE
andCREATE INDEX
queries...- There's a namespace
Phrases
which includes many objects that wrap native sql functions. You can add your own, based on theIPhrase
class.
If you're using MySql, then there's a MySqlBackup
class, which can create a full backup of a Database, including shcema and data. Yes, I know, it's cool.
There's a Visual Studio AddIn, called the "SchemaGenerator", which assists in creating the TableSchema
and a matching AbstractRecord
based on a simple language which resides in a comment.
This little tool makes rapid db prototyping easy, and gets you much further in development in significantly less time than when using any other tool I've used.
Full documentation of the syntax in Macro Structure.MD.
All the code here is under MIT license. Which means you could do virtually anything with the code. I will appreciate it very much if you keep an attribution where appropriate.
The MIT License (MIT)
Copyright (c) 2013 Daniel Cohen Gindi ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.