mardi 25 mars 2014

When using Entity Framework 6 and WebAPI 2, is using a generic repository and UoW framework overkill?


Vote count:

0




I am re-examining my implementation of the generic unit of work and repository framework.


I am using EF6, and VS2013. As such, VS contains WebAPI controller templates that auto-generate code like this:



// GET odata/UserProjects(5)/WebsiteRequiredKeywords
[Queryable]
public IQueryable<WebsiteRequiredKeyword> GetWebsiteRequiredKeywords([FromODataUri] int key)
{
return _db.Websites.Where(m => m.WebsiteId == key).SelectMany(m => m.WebsiteRequiredKeywords);
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
_db.Dispose();
}
base.Dispose(disposing);
}

private bool WebsiteExists(int key)
{ . . .


In looking at the CustomerController class in the sample code - it all looks very familiar. However, I would have to refactor the auto-generated code to make use of the generic repository syntax, modify the constructor, etc.


I am trying to now find the value in having to perform this additional work. While I have successfully used the generic repository and unit of work patterns in previous projects, for new ones, it is just more work than it's worth?



asked 1 min ago

ElHaix

2,937





Aucun commentaire:

Enregistrer un commentaire