Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From what I understand you're confusing two different responsibilities the domain objects have and the one of the view model.</p> <p>I don't see very well your model. Does the Customer has one site or more? What's the relationships between them? From my point of view what you can do a the repository level, do it at that level. So I would return a Customer with it's Site directly from the repository because you can aggregate data at repository level with joins and return it in one round-trip to the database.</p> <p>Why bother returning two separate entities Customer and CustomerSite as you know that you need them agregated in your view ? You're creating more problems then necessary. </p> <p>So returning Customer and Site from the repository at once, could be after mapped to the flat view model object for example called CustomerWithSite. For that you can use AutoMapper(<a href="http://automapper.codeplex.com/" rel="nofollow">http://automapper.codeplex.com/</a>). You can have also a "special" repository for views that already returns an object formated for the view that is issue from the queries and projections in the repository. It's up to you. But <strong>don't use your domain object for the view</strong> purpose.</p> <p>I also would not expose IQueryable outside my repository. You will get yourself in trouble. Because once, you enable other layers to manipulate your queries, the repository is no longer responsible about what is returned. Then some developpers would attempt to manipulate Iqueryable in the view, but the drawback is that it needs the connection to the database open. Not very good desgn from my point of view to keep the connection open for that. What if connection is closed before ? You would get Disposed exception while displaying objects on the view. No very good. Think also about testability.</p> <p>I don't know if it's clearer for you but be aware of the shortcomings I'm talking about.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload