views:

62

answers:

1

Hi this is a question to all experienced developers who create their web applications using ASP.NET(C#) with MySQL. I am currently using the Microsoft Enterprise Library to implement a database factory design pattern.

I have a DAL which returns a DataTable. I have a BLL that executes that DAL which returns a List<> of my DataObjects. The BLL has parameters for sorting, limit records, and filters.

What do you think is by far a good design pattern that will work for transactional queries and queries containing a number of joins (4 to 10 tables) and conditions.

I am not satisfied with the current implementation and I don't know if it'll work for me in the long run. I keep on creating DataObjects -> BLL -> DAL classes every time.

+1  A: 

For transactional queries, I'd look into the UnitOfWork pattern, which can help manage the complexities of updating several objects that are modified during a process that can be considered a single unit of work (often associated directly with a single transaction).

For queries with many joins, look into Command-Query Responsibility Segregation. The general idea behind CQRS is that our data-access patterns look very different when we are querying data (e.g., for reporting) than when we are requesting data to modify it. CQRS tells us to embrace this difference and code our access differently because the technical requirements of each type of access are truly so different.

qstarin
this is an interesting topic.
Martin Ongtangco
are these patterns doable using ORM tools. these issues keep me away from using ORM tools
geocine
These patterns are *definitely* doable using ORM tools. In fact, ORM's - mature ones at least - will support these directly. For example, NHibernate Burrow (http://nhforge.org/wikis/burrow/home.aspx) is an implementation of the Unit Of Work pattern. It makes utilizing UoW incredibly easy with NHibernate ORM and, say, ASP.Net applications.
qstarin
btw, what do you use personally? ORM tools or code generation softwares? do you have an example the one with a lot of joins and query conditions?
geocine