Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Lightweight wrapper around ADO.NET using conventions to map SQL to objects. Based on WebMatrix.Data.StronglyTyped, but without the dependency on WebMatrix.Data
C#
branch: master

README.txt

A lightweight wrapper around ADO.NET that allows you to map SQL statements to objects. 

This is based around WebMatrix.Data.StronglyTyped 
(https://github.com/JeremySkinner/WebMatrix.Data.StronglyTyped)
but without the dependency on WebMatrix.Data

Note that this requires NuGet Package Restore in order to use. 

Examples:

[Table("Users")]
public class User {
  public int Id { get; set; }
  public string Name { get; set; }
}

// Map query into a list of User objects.
using(var db = Connection.Open("ConnectionStringName")) {
  var results = db.Query<User>("select * from Users").ToList();
}

//Find record by PK
using (var db = Connection.Open("ConnectionStringName")) {
  //Assumes PK property is called ID, but this can be overriden
	User result = db.FindById<User>(100); 
}

//Insert record
using(var db = Connection.Open("ConnectionStringName")) {
  db.Insert(new User { Name = "Foo" });
}

// Update record
using (var db = Connection.Open("ConnectionStringName")) {
    var user = new User { Name = "Foo" };
    db.Insert(user);
    
    user.Name = "Bar";
    db.Update(user);
}
Something went wrong with that request. Please try again.