Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Lightweight wrapper around ADO.NET using conventions to map SQL to objects. Based on WebMatrix.Data.StronglyTyped, but without the dependency on WebMatrix.Data

Notifications You must be signed in to change notification settings

cyborgdoom/SimpleQuery

Open more actions menu
 
 

Repository files navigation

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);
}

About

Lightweight wrapper around ADO.NET using conventions to map SQL to objects. Based on WebMatrix.Data.StronglyTyped, but without the dependency on WebMatrix.Data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.