开发者

How to structure DB access in ASPNET MVC

I am new to ASPNET MVC and I'm trying to understand which is the best way to work with it; I have a DB structure and I'm using EF4 that generates the DbModel.edmx.

I could invoke Entities directly from the Controller but I'开发者_如何学Cve read somewhere that it could be better to embed all DB calls to a Repository Class and consume it from Controllers. Is it the right way to work in ASPNET MVC3?

How can DataValidation be handled with this structure?


You may want to check NerdDinner which is done by high profile programmers and there is a step-by-step book as well. It also uses patterns such as Repository, ViewModel, DataValidation, etc.

Source code: http://nerddinner.codeplex.com/
Free book: http://www.wrox.com/WileyCDA/Section/id-321793.html

There is a branch for ASP.Net MVC 3 in the source code of NerdDinner. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜