Note that there are some explanatory texts on larger screens.

plurals
  1. PORepository, Pipeline, business logic and domain model - how do I fit these together?
    text
    copied!<p>I'm designing N-tier application and I came across a difficulty which you might have a solution to. Presentation layer is MVC.</p> <p>My ORM is carried out using LinqToSQL - it's a seperate project which serves repositories.</p> <p>Each reporsitory has an interface and at least 1 concrete implementation.</p> <p>Repositories have the following methods: <code>FindAll(), Save(T entity), Delete(int id)</code></p> <p><code>FindAll()</code> returns IQueryable of some type, which means that it returns queries to which I can apply filters.</p> <p>ORM mapping has been carried out using Database First methodology, where tables were created first and then classes were generated by SQL Metal.</p> <p>I have added a Pipeline layer which works with repositories. It applies further filters to queries. E.g. <code>OrderRepository.FindAll().Where(o =&gt; o.CustomerId == 10)</code> </p> <p>Pipeline also returns IQueryable of some type, which means that I can pass it further up the layer and do more stuff with it.</p> <p>At this point I would like to move to the BusinessLogic layer, but I don't want to work with entity models any longer, I want to convert entity model to a domain model. This means that I can add validation to a model and use that model in the presentation layer. Model can't be defined in MVC project as it would be dependant on the presentation layer, so that's a no.</p> <p>I'm fairly certain that business logic (behaviour) and model must be stored seperate from pipeline, data and presentation layer. The question is where?</p> <p>For example, a pipeline has three methods: 1. FindByCustomerId 2. FindByOrderId 3. FindBySomethingElse</p> <p>All these methods return IQueryable of Order. I need to convert this to a domain model, but I don't want to do it per each method as it won't be mainteinable. </p> <p>I feel that this model is fairly robust and scalable. I just don't see what is the best place for mapping from entities to domain model and vise versa.</p> <p>Thank you</p>
 

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