Hello, I'd like ask a question about building applications in .NET that use data from a database. There are many technologies and patterns and I'm trying to connect it all.
I'm building a desktop application with local database, so I choose SQLServer CE + WinForms, but I'd like to keep this as general as possible. I'm not into other technologies (Java, etc.), but if there are some good solutions there, then you're welcome to write about them.
I'd like to ask for your suggestions, opinions and good practices that you use for building applications. Would you add or remove any of the listed layers? What technologies do you prefer?
So here are the basic layers of the application:
1) SQLServer CE/SQLServer/Oracle/IBM DB2
--------------------------------------------------
2) LINQ to SQL/Entity Framework/NHibernate/ADO.NET
--------------------------------------------------
3) Data Transfer Objects
--------------------------------------------------
4) DTO-to-BM/Data Access Objects
--------------------------------------------------
5) Business Model
--------------------------------------------------
6) MVP/MVC/MVVM/PM
--------------------------------------------------
7) WinForms/WPF/ASP.NET
1) This is the classic relational database. So the first question is whether to use stored procedures and triggers or not? I'll be using SQLServer CE, so no SPs for me, but I was wondering if peaple are pro or against them. It seems easier to me (more testable, more verifiable) NOT to put logic into the DB. The business rules would be placed in the business layer - maybe in some sort of "framework".
2) This is the DB access layer.
3) DTOs - simple POCOs. Are they needed?
4) Mapping between DTOs and BM. Hand coded, AutoMapper or maybe inheritance? Or maybe DAO - abstract objects for accessing the database that return objects from BM?
5) Business objects that build the business model. I'd put all the business rules and validation here. But is this layer needed? Or would you put all the business stuff into layer 3?
6) and 7) Building UI using BM.