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

  • Home
  • SEARCH
  • 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 8503531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:46:51+00:00 2026-06-11T01:46:51+00:00

I am using EF4.3 with a unit-of-work + repository pattern. I have a method

  • 0

I am using EF4.3 with a unit-of-work + repository pattern.

I have a method which act as a base of some other methods, here’s how the code looks.

This is my ‘base’ method:

    public static IQueryable<Deal> FindActive()
    {
        var r = new ReadRepo<Deal>(Local.Items.Uow.Context);

        return r.Find(d =>
            d.ActiveFrom <= DateTime.Now &&
            (d.ActiveUntilComputed == null || d.ActiveUntilComputed > DateTime.Now) &&
            d.Published);
    }

Here is one of the methods that calls the base method:

    public static IQueryable<Deal> FindActiveByStore(int storeId)
    {
        Guard.Default(storeId, "storeId");
        return FindActive().Where(d => d.StoreId == storeId);
    }

As you can see in FindActiveByStore, I first call FindActive, which then chains Find(). FindActive is followed by a Where() to add a secondary predicate (excuse the terminology).

I wondered if it was possible to pass a predicate to FindActive instead of using a Where(), and in fact whether it would make a difference in terms of performance.

Like this:

FindActive(d => d.StoreId == storeId)

FindActive already passes a predicate to Find() so it would need to combine both.

I’m guessing that the answers I get back will be along the lines ‘its not worth it’ in terms of effort or performance but I thought i’d ask the experts anyway.

  • 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-06-11T01:46:53+00:00Added an answer on June 11, 2026 at 1:46 am

    You can use this code (You reduce number lines of code)

    public IQueryable<Deal> FindActiveByStore(Expression<Func<Deal,bool>> predicate)
    {
      var r = new ReadRepo<Deal>(Local.Items.Uow.Context);
    
      return r.Find(d => d.ActiveFrom <= DateTime.Now 
                 && (d.ActiveUntilComputed == null || d.ActiveUntilComputed > DateTime.Now) 
                 && d.Published)
    
                 .Where(predicate);   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a unit of work and a repository using EF 4 and POCOs.
I have a MVC app using the UnitOfWork, Service Layer, Repository Pattern and EF4
Using EF4 and Linq I have a data structure which looks like this: parentid
Ive just started using EF4 with the repository pattern. Im having to call the
I am building an application using MVC3, Razor view engine, Repository Pattern with Unit
I am using EF4/RIA combo in a Silverlight application. I have multiple service methods
I have a database which is created using EF4.1 code first. The data context
First, I am using EF 4.1 and utilizing the Repository and Unit Of Work
I found some examples of how to create unit of work with ef4, i
I am using EF4 with the EDM designer. I have two tables : Users

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.