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 6330169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:49:19+00:00 2026-05-24T17:49:19+00:00

I am busy with a new project and am working on my repository layer.

  • 0

I am busy with a new project and am working on my repository layer. This will be my 2nd project using the Repository Pattern. I have been reading Scott Millett’s book Professional ASP.NET Design Patterns In referencing the case study in the book, Scott has used the Query Object Pattern in in his repository interfaces. In my previous project I used LINQ for this purpose and it worked well.

My question is as follows: What are the pros and cons of using a Query Object Pattern implementation versus using LINQ in your repository?

Here are 2 scenarios which illustrate the 2 different approaches:

1. Query Object Pattern approach

public interface IReadOnlyRepository<T, TId> where T : IAggregateRoot
{
    T FindBy(TId id);
    IEnumerable<T> FindAll();
    IEnumerable<T> FindBy(Query query);
}

2. LINQ approach

public interface IReadOnlyRepository<T, TId> where T : IAggregateRoot
{
    T FindBy(TId id);
    IQueryable<T> FindAll();
    IQueryable<T> FindBy(Expression<Func<T, bool>> query);
}

Any contributions would be helpful.

  • 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-24T17:49:21+00:00Added an answer on May 24, 2026 at 5:49 pm

    Although I think the expression trees of LINQ are just a special form of the query object pattern, because of their greater flexibility, they allow you to introduce bugs in your code that only are visible at runtime.
    I am talking about C# code that gets successfully converted to an expression tree, but is not understood by the provider that is supposed to translate it to SQL.

    Example:

    var a = new SpecialObject();
    yourRepository.FindBy(x => a.IsCorrect(x));
    

    An error like this would be impossible with an ordinary query object.

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

Sidebar

Related Questions

I am busy with a new project based on zend framework. I have created
Currently I'm busy on a project using XML messaging. I have one general schema,
I am busy converting a query using the old style syntax to the new
Hi I have a MVC 3 web project which has been deployed to Azure
I have been working on writing a library of code for my future projects.
I am busy designing a new C++ application. In this application I want to
I've quite new to Android development and specially Eclipse. I'm busy on a project
I want to retrieve a user's busy times using the new querying busy times
I have been using ADO.NET in favor of LINQ to SQL (or Entities) up
G'day, I have been involved in a project that has required my becoming familiar

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.