Hey all,
Im writing a web app which has the following layers:
ASP.NET Web Application, "Project", (Presentation Layer)
.Net Class Library, "Project.Business" (Business Layer)
.Net Class Library, "Project.Data", (Data Layer)
Im just wondering how I should communicate data between the Data and Business layers?
The first thing to come to mind is for the data layer to populate the business entity directly. e.g. (From a business entity)
public void Customer(int customerID)
{
CustomerData data = new CustomerData();
data.SelectCustomer(ref this, customerID);
}
So the CustomerData object would execute the db transaction and set the properties on the Customer object, which is passed by ref.
However..I cannot do this, as it requires that the Data assembly references the Business, and vice versa. .Net won't allow this saying its a round dependancy..
So what am I to do? Use DataSets? If I just want to return one customer's data, do I return a whole dataset? e.g. (From Customer business entity)
public void Customer(int customerID)
{
CustomerData data = new CustomerData();
ds = data.SelectCustomer(customerID);
this.CustomerName = (string) ds.Tables[0].Rows[0]["CustomerName"];
}
Seems kind of messy..?
Obviously I want to take into mind future extensibility, code management etc. What is the best practice for this?
Thanks,
Matt.
Im writing a web app which has the following layers:
ASP.NET Web Application, "Project", (Presentation Layer)
.Net Class Library, "Project.Business" (Business Layer)
.Net Class Library, "Project.Data", (Data Layer)
Im just wondering how I should communicate data between the Data and Business layers?
The first thing to come to mind is for the data layer to populate the business entity directly. e.g. (From a business entity)
public void Customer(int customerID)
{
CustomerData data = new CustomerData();
data.SelectCustomer(ref this, customerID);
}
So the CustomerData object would execute the db transaction and set the properties on the Customer object, which is passed by ref.
However..I cannot do this, as it requires that the Data assembly references the Business, and vice versa. .Net won't allow this saying its a round dependancy..
So what am I to do? Use DataSets? If I just want to return one customer's data, do I return a whole dataset? e.g. (From Customer business entity)
public void Customer(int customerID)
{
CustomerData data = new CustomerData();
ds = data.SelectCustomer(customerID);
this.CustomerName = (string) ds.Tables[0].Rows[0]["CustomerName"];
}
Seems kind of messy..?
Obviously I want to take into mind future extensibility, code management etc. What is the best practice for this?
Thanks,
Matt.