Postulate is a library of IDbConnection
extension methods for SQL Server and MySQL made with Dapper. Here are examples with FindAsync
and SaveAsync
.
using (var cn = GetConnection())
{
// find a record
var order = await cn.FindAsync<Order>(id);
// create and save
var employee = new Employee()
{
FirstName = "Whoever",
LastName = "Nobody",
HireDate = new DateTime(2002, 3, 13)
};
await cn.SaveAsync<Employee>(employee);
}
-
Entity Framework is too big and complicated. Let's keep ORM lightweight, but capable. See the list of CRUD methods here. POCO is fine, but do more with Record and navigation properties.
-
Code-first is a neat idea, but I don't want to write migrations. The SchemaSync project powers my database diff/merge commercial app SQL Model Merge. This isn't required, but it gives you a way to merge model classes to a physical database interactively.
-
In the end, inline SQL is more productive than Linq, but it needs to be isolated and testable with the Query class.
Install the Nuget package for your platform:
In the SQL Server package, there are three primary key types supported: int
, long
, and Guid
. Import the appropriate namespace for the key type you want to use: Postulate.SqlServer.IntKey
, LongKey
, and GuidKey
respectively. See SQL Server CRUD Methods
The MySql package supports only int
key types via namespace Postulate.MySql.IntKey
. See MySQL CRUD Methods
Both MySQL and SQL Server providers, as well as any new back-ends implemented should reference these base CRUD methods and surface them as extension methods.
Learn more at the Wiki.