Skip to content

Instantly share code, notes, and snippets.

@lancscoder
Created February 14, 2012 19:54
Show Gist options
  • Save lancscoder/1829694 to your computer and use it in GitHub Desktop.
Save lancscoder/1829694 to your computer and use it in GitHub Desktop.
Dapper Going Further
using (var connection = MvcApplication.GetOpenConnection()) {
connection.Delete<Post>( new Post { ID = 1 } );
}
using ( var connection = MvcApplication.GetOpenConnection() ) {
connection.Insert<Post(
new Post { Title = "Title 1", Text = "Text 1", 
PublishDate = DateTime.Now });
}
using (var connection = MvcApplication.GetOpenConnection()) {
var post = connection.Get<Post>(1);
}
using (var connection = MvcApplication.GetOpenConnection()) {
connection.Update<Post>(
new Post { ID = 1, Title = "New Title ", 
Text = "Text 1", PublishDate = DateTime.Now });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment