Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am developing a website with ASP.NET.
I have created a DAL class library project, a BLL class library project and the actual ASP.NET web application project.
From the ASP.NET web application prject I added a reference to the BLL project.
In the Bll project I created classes that map each database table. Any of these classes will call a generic method in the DAL that will return IList<T> where T can be a class.
So if I want to get all the orders from the database, I call a method in the DAL like this:
List<Order> orderList = DAL.GetAll<Order>("select * from sqlOrder");

The problem is:

If I want to get the results of a select statement which contains data from 3 different tables(therefore having 3 joins), I cannot use the generic method anymore because the raw dataset returned after running the sql statement can not be converted to any one single class.

In the end I should also mention that I preffer to build this system using .NET Framework 2.0 since I have no experience with LINQ/NHIBERNATE or any other ORM tools, but any ideas are welcomed.

Thanks in advance,

Valentin.
Posted
Updated 21-Jul-10 0:33am
v2

I also donot agree using a sql directly in BLL to get the data from DAL. I would suggest using a Provider model for write these generic methods in DAL itself and then get the results into suitably designed BLL objects.

you can get more info on provider model from this link

http://dotnetslackers.com/articles/designpatterns/HowToWriteAProviderModel.aspx

http://www.15seconds.com/issue/030317.htm

Hope this helps...
 
Share this answer
 
v2
 
Share this answer
 
Well, I can't aggree with passing SQL between layers...it belongs in the DAL only and I would strongly suggest you investigate a technology to abstract it away (such as SubSonic).

But, with the approach your using you will need to create an addditional DTO object for each combination of columns that your returning.

If you're not too attached to the strongly typed approach you could also implement a set that returns DataRows/DataTables.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900