Generic Repository & Unit Of Work

It is simple and easy to use library, using this along with Entity Framework you would be able to perform CRUD (Create, Read, Update & Delete) operations without writing much code.

You can also install the package from NuGet.

PM> Install-Package GenericRepositoryUnitOfWork

Example

public ActionResult Index()
{   
  // The below line of code will filter the List   
  var filteredList = _repo.GetAll(filter: a => a.Name.StartsWith("a"));  
 
  // The below line of code will sort the List   
  var sortedList = _repo.GetAll(sort: s => s.OrderBy(a => a.Name));    
 
  //If you are looking for performance then in your context     
  //you can disable LazyLoadingEnabled and ProxyCreationEnabled by setting it to false    
  //The below line of code will include the Child Entities   
  var includeList = _repo.GetAll(include: a => a.Albums);   
 
  return View(filteredList);   
  //return View(sortedList);   
  //return View(includeList);
}

For creating a basic application which performs CRUD operations check out Steps for implementing CRUD Operations using ASP.NET MVC4, Entity Framework and Generic Repository.

Last edited Jul 3, 2014 at 4:31 AM by arunendapally, version 14