Skip to content

Instantly share code, notes, and snippets.

@RemiBou
Created September 12, 2012 10:21
Show Gist options
  • Save RemiBou/3705772 to your computer and use it in GitHub Desktop.
Save RemiBou/3705772 to your computer and use it in GitHub Desktop.
public class CustomerController : Controller
{
private IMyDbContext _dbContext;
public CustomerController(IMyDbContext dbContext)
{
_dbContext = dbContext;
}
public ActionResult Index()
{
return View(_dbContext.Customers.OrderBy(c => c.Name).ToList());
}
}
public interface IMyDbContext
{
IQueryable<Customer> Customers { get; set; }
}
public class MyDbContext : IMyDbContext,DbContext
{
public IQueryable<Customer> Customers { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment