Last active
December 14, 2015 11:58
-
-
Save hudo/5083014 to your computer and use it in GitHub Desktop.
sample ef config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* data context */ | |
class MyDataContext : DbContext, IDataContext | |
{ | |
public IDbSet<BlogPost> BlogPosts { get; set; } | |
} | |
interface IDataContext | |
{ | |
IDbSet<BlogPost> BlogPosts { get; set; } | |
int SaveChanges(); | |
} | |
/* mvc controller, hooked to some ioc/di */ | |
public class BlogController | |
{ | |
private IDataContext _dataContext; | |
public BlogController(IDataContext db) { | |
_dataContext = db; | |
} | |
} | |
/* structuremap sample config */ | |
For<IDataContext>().HybridHttpOrThreadLocalScoped().Use<MyDataContext>(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment