Click here to Skip to main content
15,888,251 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
Hi
I using C# and developing a windows forms project.
I am using 3 tier architecture (UI layer, Business Logic, Data Access).

I have a table named "Customer" of having around 100 fields in it.

I want to add new Customer, am assigning all these 100 fields into the Business Layer "Customer Class", then calling a "insertCustomer" method of business layer.

Now, from business layer, after all validations, how can i pass the whole "customer" class together into Data access layer, so that i can make the actual insert query with all field values?.

or do i need to assign each field into variables and pass these variables as parameters from business layer to data access layer?..

I hope, there must be some another easy way.
Kindly guide me.
Thanks
Jim

What I have tried:

I have tried instantiating the class in the business layer and pass it to data layer.
but not working as it creates new instance.
Posted
Updated 29-Feb-16 22:40pm
Comments
PIEBALDconsult 29-Feb-16 11:20am    
That's not three-tier; those are layers, there's a difference.
You would have to Improve Question to include some code, whatever problem you're having isn't clear.
Sascha Lefèvre 29-Feb-16 11:37am    
What stops you from simply passing the Customer-object to the DAL?
PeejayAdams 4-Mar-16 6:47am    
There is something very wrong with your database design if you have a hundred columns in a table. If you don't address that first, anything you try to do in code is going to be a nightmare. Look at the basics of RDBMS and normalization before you go any further.

1 solution

C#
Hi Jim,
    
    You just need to pass the customer object to your Data Access Layers method.

public class Customer
{
   field1; field2;.... field100;
}

Business layer:
public someMethod{
Customer objCust = new Customer ();
objCust.field1 = val1;
.
.
.
objCust.field100 = val100;

DAL.test(objCust);
}


DAL:

public test(Customer objCust)
{
   Your Database Operations...
}
 
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