I recently learned ASP.NET MVC (I love it). I\'m working with a company that uses dependency injection to load a Repository instance in each request, and I\'m familiar with
There is a ready to use solution at URF - Unit of Work & (extensible/generic) Repositories Framework. It will save you a lot of time. They implemented a generic repository (also there is an async repository). For extending any repository they have used extensions like this:
public static decimal GetCustomerOrderTotalByYear(this IRepository repository, string customerId, int year)
{
return repository
.Queryable()
.Where(c => c.CustomerID == customerId)
.SelectMany(c => c.Orders.Where(o => o.OrderDate != null && o.OrderDate.Value.Year == year))
.SelectMany(c => c.OrderDetails)
.Select(c => c.Quantity*c.UnitPrice)
.Sum();
}
Some classes like QueryObject may be an overwork depending on your project but overally it is good solution to help you get up and running.