R
Ranginald
Hi,
I am confused about the business layer vs. the dal layer and I could
use some help.....
I. If the DAL layer has all the methods to work with the db with a
typed data sey (e.g. ShowProducts(), InsertProducts() ), then why does
the business layer need to wrap these methods with set/get?
II. Also, if the code for show products(), created in the DAL, is a
simpe INSERT SQL statement, then where does the validation go? I've
read that it's supposed to go in the business layer, so are you
supposed to do something like this:
businessLayerCode.cs
public static void ShowProductsUsingDALMethod ()
// call the DAL's ShowProducts Method
// that was defined with tableAdapter
public static void InsertProductsUsingDALMethd()
// write verification code such that you cannot insert a duplicate
product
// e.g. rule = "no two products can have the same name value in
tblProducts.Name"
if {
verification code is valid
InsertProducts()
}
else
//display message that you can't use this product name
==== is this where the verification code goes? It doesn't make sense
to me to make a call to the database (using a stored procedure) to
check that there isn't another product named "truck", and then make a
second call to insert the product "truck".
Thanks!
-David
I am confused about the business layer vs. the dal layer and I could
use some help.....
I. If the DAL layer has all the methods to work with the db with a
typed data sey (e.g. ShowProducts(), InsertProducts() ), then why does
the business layer need to wrap these methods with set/get?
II. Also, if the code for show products(), created in the DAL, is a
simpe INSERT SQL statement, then where does the validation go? I've
read that it's supposed to go in the business layer, so are you
supposed to do something like this:
businessLayerCode.cs
public static void ShowProductsUsingDALMethod ()
// call the DAL's ShowProducts Method
// that was defined with tableAdapter
public static void InsertProductsUsingDALMethd()
// write verification code such that you cannot insert a duplicate
product
// e.g. rule = "no two products can have the same name value in
tblProducts.Name"
if {
verification code is valid
InsertProducts()
}
else
//display message that you can't use this product name
==== is this where the verification code goes? It doesn't make sense
to me to make a call to the database (using a stored procedure) to
check that there isn't another product named "truck", and then make a
second call to insert the product "truck".
Thanks!
-David