Note that there are some explanatory texts on larger screens.

plurals
  1. PORe-shaping data (?) with Linq-To-Sql, DDD and the Repository Pattern
    primarykey
    data
    text
    <p>I have the following schema in my database:</p> <p><img src="https://i.stack.imgur.com/gKMzJ.png" alt="enter image description here"></p> <p>(OK, not really, but it works for the context of my question.)</p> <p>In my Domain Model, I have a RestaurantMenu (root entity) class which contains a collection of MenuItem objects which look like:</p> <pre><code>public class MenuItem { public String Category { get; set; } public Guid ID { get; set; } public String Name { get; set; } public Decimal Price { get; set; } } </code></pre> <p>I want to be able to query my repository to return the list of MenuItem objects based on the Restaurant ID and menu type (name). As you can see, this means that I need to do a bunch of joins and return the flattened view of the menu information. I am using Linq-to-SQL (not my choice) for the data access technology.</p> <p>How do I setup the L2S query to return the desired data?</p> <p>Next question is more for the DDD folks, I have a separate use case that works with the Menu, Category and Item tables more directly for creating and editing Menu "templates". As such, I see Menu as an Aggregate Root and have a MenuService as a facade for the Menu class in my domain model and a MenuRepository that handles data access (get, find, delete and save). A few questions around this aspect:</p> <p>Should I have a separate repository (and service) for the RestaurantMenu class or should this be provided through the same channels?</p> <p>Is RestaurantMenu better served as a sub-class of Menu, perhaps?</p> <p>(Keep in mind that I also need the ability to 'save' to the ItemPricing table when the restaurant admin is 'editing' the menu for his restaurant. This won't change the Menu/Category/Item table contents in any way - only the ItemPricing data.)</p> <p>Your thoughts on my approach are appreciated.</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