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?
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.Employe eId = 1;
objemployeelistDTO.Employe eName = "jagadeesh";
objemployeelistDTO.Designa tion = "SSE";
objEmployeeDAL.InsertEmplo yee(objemp loyeelistD TO);
thats it
you should define this "InsertEmployee" method in DAL.
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.Employe
objemployeelistDTO.Employe
objemployeelistDTO.Designa
objEmployeeDAL.InsertEmplo
thats it
you should define this "InsertEmployee" method in DAL.
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?
Now is there any way with interfaces? If Yes, How?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you.