Where do objects merge/join data in a 3-tier model?

Posted by BerggreenDK on Stack Overflow See other posts from Stack Overflow or by BerggreenDK
Published on 2010-06-05T14:06:25Z Indexed on 2010/06/05 14:12 UTC
Read the original article Hit count: 250

Its probarbly a simple 3-tier problem. I just want to make sure we use the best practice for this and I am not that familiary with the structures yet.

We have the 3 tiers:

  • GUI: ASP.NET for Presentation-layer (first platform)
  • BAL: Business-layer will be handling the logic on a webserver in C#, so we both can use it for webforms/MVC + webservices
  • DAL: LINQ to SQL in the Data-layer, returning BusinessObjects not LINQ.
  • DB: The SQL will be Microsoft SQL-server/Express (havent decided yet).

Lets think of setup where we have a database of [Persons]. They can all have multiple [Address]es and we have a complete list of all [PostalCode] and corresponding citynames etc.

The deal is that we have joined a lot of details from other tables.

{Relations}/[tables]

  • [Person]:1 --- N:{PersonAddress}:M --- 1:[Address]
  • [Address]:N --- 1:[PostalCode]

Now we want to build the DAL for Person. How should the PersonBO look and when does the joins occure? Is it a business-layer problem to fetch all citynames and possible addressses pr. Person? or should the DAL complete all this before returning the PersonBO to the BAL ?

Class PersonBO 
{
    public int ID {get;set;}
    public string Name {get;set;}
    public List<AddressBO> {get;set;} // Question #1
} 

// Q1: do we retrieve the objects before returning the PersonBO and should it be an Array instead? or is this totally wrong for n-tier/3-tier??

Class AddressBO 
{
    public int ID {get;set;}
    public string StreetName {get;set;}
    public int PostalCode {get;set;} // Question #2
} 

// Q2: do we make the lookup or just leave the PostalCode for later lookup?

Can anyone explain in what order to pull which objects? Constructive criticism is very welcome. :o)

© Stack Overflow or respective owner

Related posts about c#

Related posts about linq-to-sql