Last post Jul 02, 2010 01:43 PM by atconway
Jul 02, 2010 06:14 AM|arjit.malviya|LINK
I am working on a 3 tier architecture. I collect data from user input(Presentation layer) and send it to BL using get set methods(in BL), i am able to do so as I am creating the object of BL in Presentation Layer.
Now I have a problem in passing this data from BL to DL. In DL, I have SQL statements (calling procedures) to access database. How should I pass data from BL to DL?, using generic data structures or using get set method?.
Note: It is not possbile to create an object of BL in DL bcoz of circular dependency as I have already created the object of DL in BL.
Any help will be aprreciated.
business logic layer
3 tier architecture
Jul 02, 2010 08:55 AM|iGulfam|LINK
Pass data to DL using function parameters.
Jul 02, 2010 01:43 PM|atconway|LINK
How should I pass data from BL to DL?, using generic data structures or using get set method?.
There are several ways you can do this depending on how complex you would like to get, and the needs of your application.
1. Use only the required elements of the Business Object and pass the individual properties only to the DAL for processing. This typically is not the best model, but it can work in smaller projects.
2. Pass the entire object, but in order to avoid the circular dependency you were mentioning, you are going to need to use DTOs (Data transfer Objects) that both layers understand. They are Plain Old CLR Objects POCO that really only contain the data on
properties, but no business logic or validation. This layer in some diagrams runs parallel to the (3) tiers. Then these DTOs can be mapped by the Data Mapper to the Domain Model which consists of the data, validation, rules etc. Look at the following for
some more information:
Pros and Cons of Data Transfer Objects
3. Extract out some of the DAL code into the BLL to build up the ADO.NET objects like SQL Command objects, DataSets, etc. at the lowest level of the Business Layer using the business objects, that then can be passed on to the DAL. This breaks a lot of the
layering rules because some of the data types are created in the BLL, but this would prevent you from having the DAL understand the BLL. This means the DAL and BLL speak in terms of ADO.NET objects only. It limits the scalability but its an option.
4. Use an ORM tool like the Entity Framework to help map this database data into entities. See below for more information:
Entity Framework Overview:
There are a ton of other architectures and possibilities for passing the data between layers and entire books or portions of books on this topic. Based on your questioning, I thought these might be some decent options.
Hope this helps!