Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC - Service Layer - Business Layer - Data Layer (EF) - SQL DB :: Data Transfer?
    primarykey
    data
    text
    <p>I am planning to create 3 tier application using ASP.NET MVC as UI tier, WCF as Business tier and SQL DB as the database.</p> <p>My Business tier would split as Service Layer (WCF), Business Layer (Business logic, Business Model), Data Layer (Entity Framework - DB first).</p> <ul> <li><p>Data layer would implement the repository methods like Get, GetById, Update, Insert using the Entity Frameworks's Entities.</p></li> <li><p>Business layer consists of Business rules and its Models. (this is in POCO).</p></li> <li><p>The service layer would just expose the business functionality as possible service methods.</p></li> <li><p>The "M" in the MVC would just be the presentation model - used either by the Controller to get it converted to JSON / XML and give it to the View or to be consumed by the View directly.</p></li> </ul> <p>Although the above mentioned approach is common I would still like to get it confirmed if this is a good design ?</p> <p>My real question is about the data transfer between the layers ( UI (MVC) - Service (WCF) - Business - Data layer)</p> <p>Lets say I have a GET operation initiated to retrieve Account and its Traits from database. In database its represented as two different tables.</p> <ul> <li>Accounts --> AccountNumber, Name, Type</li> <li>AccountTraits --> Id, AccountNumber, Category, etc..</li> </ul> <p>Within Datalayer I want to write a method to get these two tables records for a given<br> AccountNumber using EF.</p> <p>My Business Model has a two classes called Account and AccountTraits. The AccountTraits's object collection is aggregated into Account class. </p> <p>like,</p> <pre><code>public class Account { string AccountNumber; List&lt;AccountTraits&gt; Traits; } </code></pre> <p>Now, If I want to populate these Domain objects with its data I can use the EF query something like the below in my data layer.</p> <pre><code>public IEnumerable&lt;Account&gt; GetAccountAndItsTraits(string AccountNumber) { var query = from a in db.Accounts select new Accounts() { AccountName = a.AccountName, Traits = from t in a.AccountTraits .... return query; } </code></pre> <ol> <li><p>Is this the rite approach to populate the Business model POCO from Data layer (EF) ?</p></li> <li><p>Now, after applying some business logic I would like to return these collection to the UI. How do I transfer these to the Service layer and how do I give it to the UI Model ?</p></li> <li><p>Should I have to define DataContract in WCF with exact class definition as Business model and then <strong>"copy the data"</strong> to it and give it to the UI ? Then the UI should get the data from the WCF proxy objects and <strong>"copy to its Presentation Model"</strong> (which is again should have its own Accounts and AccountTraits - may be with some extra fields)?</p></li> </ol> <p>It would be great if you can throw some lights on these topics.</p> <p>Thanks!</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.
 

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