entity framework - Asp.net mvc4 common data -


is there best practise share database data accross controllers , viewmodel. example: products , catgories have available (one case should provide list of categories in edit view of products in admin area of site) , have data updated in case of modification (ie in previous case adding category...). not want have same piece of code reading database (i'm using ef5) in each controller...

use repository pattern achieve 1 or more of following objectives:

  • you want maximize amount of code can tested automation , isolate data layer support unit testing.

  • you access data source many locations , want apply centrally managed, consistent access rules , logic.

  • you want implement , centralize caching strategy data source.

  • you want improve code's maintainability , readability separating business logic data or service access logic.

  • you want use business entities typed can identify problems @ compile time instead of @ run time.

  • you want associate behavior related data. example, want calculate fields or enforce complex relationships or business rules between data elements within entity.

  • you want apply domain model simplify complex business logic.

more information here : http://msdn.microsoft.com/en-us/library/ff649690.aspx


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -