I am using Entity framworke in my project. I am using 3 layer architecture ( Presentation layer(PL), Business logic layer(BLL) and Data Access Layer(BAL)). Entity framework define all entity as well as CRUD operation to BD.
I have encountered one basic problem. Suppose i need to Insert customer in DB. I want to
do is as follow
---------------PL-------------
Customer ObjCustomer=new Customer();
//init object
ObjCustomer.Name="";
--------------
------------
BLL.InsertCustomer(ObjCustomer)
------------------------------------------------
-------------------BLL---------------
DAL.InsertCustomer(ObjCustomer)
------------------------------------
-------------------DAL---------------
CustomerReporitory.InsertCustomer(ObjCustomer)
------------------------------------
Now problem is that customer is defined in DAL as part of EF. It is not advisable to take DAL ref in PL. I want to pass custom class type like customer as parameter. How to do that. Please me some sample code.
The Customer in your presentation layer shouldn’t be the Customer from your business or data layer. The Customer in your presentation layer should be something similar to a ViewModel, so it should only carry attributes and be declared in the business layer. That is the type of object that should be sent to the business layer for CreateCustomer, which in turn creates a business entity or DAO from it and passes it for persistence.
Presentation layer
Business layer
Data layer