Which is good architecture with Fluent NHibernate?
I m developi开发者_开发知识库ng an application with MVC 3 and Fluent NHibernate. i want to know what will be the best architecture for application , like should we separate the Business layer , DAL and respository layer, define entity class and mapping class in business later , all the interfaces are in repository and all the data logic in DAL. any ideas what is the best way to handle the application ?
Thanks
You could define your business entities into a separate layer. Then you could have interfaces defining the CRUD operations with those business entities (repositories). Then you would have a specific implementation of those repositories: in your case using NHibernate. This is where you would have your data access logic and FluentNHibernate mappings. Finally you would have a service layer which will define complex business operations consisting of multiple simple CRUD operations on your business entities. The business layer could also contain business validation logic.
The service layer and the data access layer will be weakly coupled thanks to the interfaces that your repositories implement, the business layer shouldn't know about the specific implementations of those repositories.
Finally your MVC controllers will work with the service methods and business entities. It is in the UI layer (MVC application) where you would also define view models, so that controller actions could map between the business entities and the view models and pass those view models to the views.
A very good open source project to take a look at is CodeCampServer
This is where I started, and it is using the stack that you are interested in (MVC, Fluent NHib)
In my opionion S#arp Architecture is a great code-base to learn about well designed, loosely coupled and domain driven design architecture for a ASP.NET MVC projects using NHibernate with Fluent NHibernate as ORM.
精彩评论