Link to home
Start Free TrialLog in
Avatar of GouthamAnand
GouthamAnand

asked on

How to pass the object instead of individual parameters to Data access layer?

I have Business Objects layer having all the BOs. And I have data access layer. Now I want to pass the object (instead of individula parameters) to data access layer. I do not have the reference of Entity in Data access layer. How to pass the objects instead of parmeters? Can anyone explain me with small exapmle?
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

If you DAL won't recognise you're business object (presumably because you don't reference the BLL dll in your DAL) then you don't have much option unless you alter your DAL.
Create a properties class where define all the related properties.

and assign all the values to this object. send this object to the DAL class.

For ex: Properties class is EmployeeListDTO, where i am having EmployeeId, EmployeeName, Designation properties.

import properties namespace in DAL,BAL and UI.
in BAL or UI ,


assign variables like below

EmployeeDAL objEmployeeDAL = new EmployeeDAL();
EmployeeListDTO objemployeelistDTO = new EmployeeListDTO();
objemployeelistDTO.EmployeeId = 1;
objemployeelistDTO.EmployeeName = "jagadeesh";
objemployeelistDTO.Designation = "SSE";

objEmployeeDAL.InsertEmployee(objemployeelistDTO);

thats it

you should define this "InsertEmployee" method in DAL.
Avatar of GouthamAnand
GouthamAnand

ASKER

If I refer BO layer in DAL then it leads circular reference. And also I am refering the upper layer (BO) in lower layer (DAL) which I don't want to do.
Now is there any way with interfaces? If Yes, How?
ASKER CERTIFIED SOLUTION
Avatar of jagssidurala
jagssidurala
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.