locked
dbml, Entities: Middle Tier or Data Access Layer RRS feed

  • Question

  • User-1722064047 posted

    Folks,


    In a standard 3-tier architecture, where would you put your dbml file?

    Is your answer the same for a ado.net entity data model?

    If the dbml file is in the middle tier, then do you have a data layer?


    Regards,


    Brett

    Tuesday, June 1, 2010 5:30 PM

Answers

  • User-1465070452 posted

    your dbml is your data layer..

    the middle layer is basically .. where you apply your business rule on the data retrived  from the dbml..


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 1, 2010 8:30 PM
  • User-2004844803 posted

    Sure you can access them but when someone say you shouldnt I think its because off the separation into layers. In a layered architecture each layer should not have any relations to layers above it self. With that said you can actually have a layer access any off the lower layers without harming the design.

    Here is how I would solve your problems. Separate your domain logic (entities and dbml files) into one project and put your service interfaces into another. Hide all your dbml code inside that project and expose access methods for your entites. this way your upper layers can access entites without accessing a service interface and use the service interface where you need to manipulate your entites in any way (performing lazy loads, applying business rules, accessing aggregates etc). would this work for you?

    You can (should) also create your own entites and not exposing the ones that are auto-created with Linq2Sql. Use an entity mapper to map the auto-created entites to your own entites (a really good and fast one that is use a lot is DynamicFillerLib).


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 2, 2010 3:52 AM
  • User-446933086 posted

    Hi

    If you are following the 3 tier architecture. Than the Dbml

     Will be your Data Access Layer.

    You can direct access the in code file of page. At that point you will be out of 3 tier architecture

    For details please visit

    http://msdn.microsoft.com/en-us/library/aa581776.aspx
    http://msdn.microsoft.com/en-us/library/ms973829.aspx
    http://www.microsoft.com/belux/msdn/nl/community/columns/hyatt/ntier1.mspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 2, 2010 7:11 AM

All replies

  • User-1465070452 posted

    your dbml is your data layer..

    the middle layer is basically .. where you apply your business rule on the data retrived  from the dbml..


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 1, 2010 8:30 PM
  • User-1722064047 posted

    So,


    I have always understood that the front end can not access the data layer directly.

    If so, then...

    If I have no business rules for a table, then I have a bunch of pass through methods for the front end to access?

    In the front end, I can not access the objects created by the DBML file?

    Basically, It seems that Linq2SQL and entities make it difficult to have a real separation of the layers.

    Any thoughts anyone?


    Regards,

    Brett




     

    Tuesday, June 1, 2010 8:46 PM
  • User-2004844803 posted

    Sure you can access them but when someone say you shouldnt I think its because off the separation into layers. In a layered architecture each layer should not have any relations to layers above it self. With that said you can actually have a layer access any off the lower layers without harming the design.

    Here is how I would solve your problems. Separate your domain logic (entities and dbml files) into one project and put your service interfaces into another. Hide all your dbml code inside that project and expose access methods for your entites. this way your upper layers can access entites without accessing a service interface and use the service interface where you need to manipulate your entites in any way (performing lazy loads, applying business rules, accessing aggregates etc). would this work for you?

    You can (should) also create your own entites and not exposing the ones that are auto-created with Linq2Sql. Use an entity mapper to map the auto-created entites to your own entites (a really good and fast one that is use a lot is DynamicFillerLib).


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 2, 2010 3:52 AM
  • User-1722064047 posted

    Thanks,


    I will look into DynamicFillerLib.  That seems like it might fill the gap I am having between true separation on layers and the inefficiency (int coding time) of redundantly programming an middle tier object model.

    I would still like to hear more opinions!


    Regards,


    Brett

    Wednesday, June 2, 2010 6:13 AM
  • User-446933086 posted

    Hi

    If you are following the 3 tier architecture. Than the Dbml

     Will be your Data Access Layer.

    You can direct access the in code file of page. At that point you will be out of 3 tier architecture

    For details please visit

    http://msdn.microsoft.com/en-us/library/aa581776.aspx
    http://msdn.microsoft.com/en-us/library/ms973829.aspx
    http://www.microsoft.com/belux/msdn/nl/community/columns/hyatt/ntier1.mspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 2, 2010 7:11 AM
  • User-1237044210 posted

    @toas1: your explanation is so details, I really like that. 

    @Brett: anyway as long as you follow some principles and made it work well for you. As me, you should put you dbml in DAL, if you research about it, you can see that LINQ to Entities for hard to Unit Testing, so I think you should use EF4. And why you shouldn't use your entities in front end, that because according to Martin Powler, you shouldn't throw your Domain entities to other layer. But if you don't follow DDD, you can use it for front end. IMHO

    @idreesbari: Good referenced, man!

    Thursday, June 3, 2010 12:36 PM
  • User-2004844803 posted

    @toas1: your explanation is so details, I really like that. 

    thanks Wink

    Thursday, June 3, 2010 1:35 PM
  • User-1722064047 posted

    Thank you for taking the time to reply.


    Can you define "Domain Entities" for me?

    And how exactly does DDD ("Domain-driven design"?) apply to the issue?


    Thursday, June 3, 2010 2:59 PM