Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 765541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:54:11+00:00 2026-05-14T16:54:11+00:00

In the context of the n-tier application, is there a difference between what you

  • 0

In the context of the n-tier application, is there a difference between what you would consider your data access classes to be and your repositories?

I tend to think yes but I just wanted to see what other thought. My thinking is that the job of the repository is just to contain and execute the raw query itself, where as the data access class would create the context, execute the repository (passing in the context), handle mapping the data model to the domain model and return the result back up…

What do you guys think? Also do you see any of this changing in a Linq to XML scenario (assuming that you change the context for the relevant XDocument)?

Cheers Anthony

UPDATE:

This is the way that I would have typically implemented things previously:

public class TermBl : ITermBl
{
    public IEnumerable<ITerm> GetAll(IListParameter criteria)
    {
        //Any pre business logic

        var dataLayer = this.CreateDataLayer();
        var result = dataLayer.GetAll(criteria);

        //Any post business logic

        return result;
    }

    ... Other methods
}

public class TermDa : ITermDa
{
    public IEnumerable<ITerm> GetAll(IListParameter criteria)
    {
        //Linq query
        var dataResult = ....ToList()

        var mappedResult = this.FromDataToDomain(dataResult);   
        //Note the mapping isn't done in this object, the actual 
        //  mapping is handled by a separate component

        return mappedResult;
    }

    ... Other methods
}

Do you see any inherent problems here with the pattern in general…

As for the repository where I have been thinking of using the it is instead of having the query directly in the TermDa’s GetAll method I would change it to look something more like this:

public class TermDa : ITermDa
{
    public IEnumerable<ITerm> GetAll(IListParameter criteria)
    {
        var repository = this.CreateRepository();
        var dataResult = repository.GetAll(..., criteria).ToList();

        var mappedResult = this.FromDataToDomain(dataResult);

        return mappedResult;
    }

    ... Other methods
}

public class TermRepository : ITermRepository 
{
    public IQueryable<ITerm> GetAll(IMyContext context, IListParameter criteria)
    {
        //Linq query
        return  ...;
    }

    ... Other queries
}

Is this how you guys see it working or not really… With or without the repository I see either of the above totally protecting the business layer from knowing anything about the data access methods/technology used…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:54:11+00:00Added an answer on May 14, 2026 at 4:54 pm

    Yes, there is a major difference.

    • A DAL (such as a Table Data Gateway) is a database concept. It is responsible for issuing queries to the database and returning record sets.

    • A repository is a domain concept. It is responsible for accepting structured requests and returning strongly-typed objects.

    Very different in practice.


    Update:

    The question seems to reflect a significant amount of confusion, so let me try to clarify with a code example. Here’s a design you might use if you weren’t using any ORM and were doing all of your own mapping instead. None of this is production-quality code, it’s just for educational purposes:

    Data Access:

    public interface IOrderData
    {
        IDataReader GetOrder(int orderID);
    }
    
    public interface IOrderDetailData
    {
        IDataReader GetOrderDetails(int orderID);
    }
    
    public interface IProductData
    {
        IDataReader GetProduct(int productID);
    }
    

    Domain:

    public class Order
    {
        public int ID { get; set; }
        public DateTime Date { get; set; }
        public OrderStatus Status { get; set; }
        // etc.
        public IList<OrderDetail> Details { get; set; }
    }
    
    public class OrderDetail
    {
        public int ID { get; set; }
        public Product Product { get; set; }
        public int Quantity { get; set; }
    }
    

    Mapping:

    public interface IDataMapper
    {
        Order MapOrder(IDataRecord record);
        OrderDetail MapOrderDetail(IDataRecord record);
        Product MapProduct(IDataRecord record);
    }
    

    Repository:

    public interface IOrderRepository
    {
        Order GetOrder(int orderID);
    }
    
    public class OrderRepository
    {
        // These get initialized in the constructor
        private readonly IOrderData orderData;
        private readonly IOrderDetailData orderDetailData;
        private readonly IProductData productData;
        private readonly IDataMapper mapper;
    
        public Order GetOrder(int orderID)
        {
            Order order;
            using (IDataReader orderReader = orderData.GetOrder(orderID))
            {
                if (!orderReader.Read())
                    return null;
                order = mapper.MapOrder(orderReader);
            }
            using (IDataReader detailReader = 
                orderDetailData.GetOrderDetails(orderID))
            {
                while (detailReader.Read())
                {
                    OrderDetail detail = mapper.MapOrderDetail(detailReader);
                    detail.Product = ...;  // Omitted for brevity, more reading/mapping
                    order.Details.Add(detail);
                }
            }
            return order;
        }
    }
    

    Is this making more sense now? The DAL is dealing with data. The concrete Repository may encapsulate data access classes but the abstract repository (its public interface) only deals with domain classes.

    Once again I’ll just remind readers that this is not even close to production-quality code, and that most apps today use an ORM or at least some better form of automatic mapping. This is for illustrative purposes only.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Context: There's an application where you draw things on canvas. Where user clicks there's
I think I understand sharding to be putting back your sliced up data (the
Context: I'm in charge of running a service written in .NET. Proprietary application. It
Is N-Tier Architecture only the physical separation of code or there is something more
I have a n-tier application based on pretty classic different layers: User Interface, Services
we have an JSF2.0 / EJB3.0 Application. Is it possible to access user's language/locale
I'm creating my first N-Tier MVC application and I've run into a road block
Context: the application I'm trying to make does not display a form initially, but
Context: I'm working with a relatively simple winforms application, written in VB.NET on the
I have a repository class that wraps my LINQ to SQL Data Context. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.