I have a 3-tier web application wit ha bunch of simple forms. One to list records, one to edit a single record, etc. The works.
I have a DataLayer where my EDMX is. I have an App Layer where my POCOs are. I haev a BusinessLayer with all my controller classes, etc. (not MVC!) I have a UI layer where my web UI is.
The EDMX has many, many tables wit ha lot of navigation properties. Of course, when I fetch the data in one of my controllers, e.g. GetCustomerById(int id), I create the Object context and close it when I'm done.
However, the ObjectContext
is out of scope when I try to access the navigation properties in the UI layer.
Should I do (using MyContext = new MyContext()) {... }
in the web layer?? that does not seem right.
Should I create another set of POCOs that I populate from the entities' data from the BizLayer?
What happens when I want to save data entered in a web form? Would I call a BizLayer controller e.g. SaveCustomer()?
My question is, how do you design the web UI layer if I want to be able to properly access the navigation properties of an entity?
Note: EDMX is set to LazyLoading.