Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In 3Tier we are making Business Object, Data Access Layer per Entity(Table)

Like PartyMasterBO, PartyMasterDAL
ProductMasterBO, ProductMasterDAL


I am trying to fetch records by joining two or more entities

My question is
where to put below query

Select *
from PartyMaster, ProductMaster, Registration
where Registration.party_id=PartyMaster.party_id and Registration.product_id=ProductMaster.Product_id


Thanks and reply
Posted

Hi,

Before even suggesting anything i would want to understand that , are you talking about 3 layers/Tiers..

I am assuming that you want to follow 3 layer approach, in that case from the UI make the call to get

public void Get()
{
 BL.Get();
}


In the BL, Get the data...in case of any exceptions based on the requirement log the details either to file,db etc...I would suggest you to use Enterprise library 5, since it gives you all the feature by default with just few configurations.

public result Get()
{
DAL.Get();
}


In the DAL, based on the business functionality, invoke the query, Now again here either you can make use of T-Sql or Stored procedure, my preference would be to use stored procedure since it gives you lot of flexibility in terms of maintainability,security,modularity etc.

In DAL also i would suggest you to use the Enterprise library.

Dal
public result Get()
{
  //Invoke the right stored procedure and get the data
}


I hope this helps!.

Regards,
-Vinayak
 
Share this answer
 
You Should use the following :

- Your sql query should be stores as a 'Stored Procedure' in the sqlserver
- the name of the stored procedure should be pass from the busniss layer to the DAL as string parameter and your DAL should deal with it.
 
Share this answer
 
Comments
Khaniya 2-Jul-10 3:56am    
Reason for my vote of 4
I think it is best answer compare to others
Your business entities should not be independent it should be as per your database relationship in.

For example you store Employee and EmployeeAddress in two separate tables and define a foreign key [1-n] relationship between them. So your Employee object should contain a collection of Addresses.
First identify the association and composition of these entities, once this is done then it will be very easy for you to populate any object.
 
Share this answer
 
You query should ideally go into the DAL.
 
Share this answer
 
Comments
Khaniya 26-Aug-10 10:00am    
Hi Abhinav
Every Entity have DAL, so in which DAL query will goes.

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