Results 1 to 2 of 2

Thread: Keeping the DAL seperated from the UI in MVC

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Keeping the DAL seperated from the UI in MVC

    HI All,

    I have a Repository Layer using Entity Framework and this stores all my data object structures. I then have a service layer that uses the repository. i.e. I may have a User object in the repository and I request a User object perhaps based on username password in my service Layer. My controller that Makes the request to the service layer wants a User object but I dont want to give a direct reference to the data layer from my controller. I only want my service layer to know about the DAL. How can I best approach this such that I can still give the Controller the Structure it needs to populate the view.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Keeping the DAL seperated from the UI in MVC

    Define your EF model in a separate project. The DAL project and the BLL project can both reference it. You might also reference that project in the UI project. Alternatively, you might define data transfer objects (DTOs) in yet another project and the reference that in the UI and the BLL. The BLL then does the translation between entities and DTOs on the way up and the opposite on the way back down. If you're not using a web service or your EF entities are lightweight then you might not use the DTOs. So, DAL references EF, BLL references DAL and EF and DTO if it exists, UI references BLL and DTO if it exists and EF if it doesn't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width