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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:36:32+00:00 2026-05-23T03:36:32+00:00

please take a look at the following snippet: public IEnumerable<T> Query(Expression<Func<T, bool>> filter) {

  • 0

please take a look at the following snippet:

public IEnumerable<T> Query(Expression<Func<T, bool>> filter)
{
    return filter != null ? this.ObjectSet.Where(filter) : null;
}

As for example:

public IQueryable<Department> Query(Expression<Func<Department, bool>> filter)
{
    return _context.Departments.Where(filter);
}

(original source: http://blogs.microsoft.co.il/blogs/gilf/archive/2010/06/21/revisiting-the-repository-and-unit-of-work-patterns-with-entity-framework.aspx)

Can anyone provide some concrete examples of how to go about actually calling the second method with an actual query?

Thanks!

  • 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-23T03:36:33+00:00Added an answer on May 23, 2026 at 3:36 am

    To say get all departments with Sales over $100

    var deparments = deparmentsRepository.Query(d => d.TotalSales > 100.0m);
    

    Func and Expression> can both be declared the same way using lambda syntax.

    In fact there’s an example in the article (in the last code snippet) you linked to already for this.

    foreach(var department in uow.Departments.Query(d => d.Budget > 150000)) { ... }
    

    Given that Query returns IQueryable there’s no reason you can’t build into more complex queries.

    var deparments = deparmentsRepository.Query(d => d.TotalSales > 100.0m)
        .Select(d => new { ... });
    

    Assuming Manager and Department have a foreign key you don’t need that join.

    var deparments = deparmentsRepository.Query(d => d.Manager.Name.StartsWith("A"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please take a look at the following code: Public Sub Method(Of TEntity As EntityObject)(ByVal
Please take a look at the following line <TextBox Text="{Binding Price}"/> This Price property
Please take a look at this code: class Foo { public $barInstance; public function
Please take a look at the following code: public static void main(String[] args) {
THis is myDB Class //Please take a look at public Cursor getplaces() --- Am
Please take a look at the following snippet from ipython: In [122]: len(netean) Out[122]:
Please take a look at the following simple code: class Foo { public: Foo(){}
Please take a look at this: protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int
Please take a look at following code: #include <stdio.h> #include <iostream> using namespace std;
Please take a look on the following pseudo-code: boolean blocked[2]; int turn; void P(int

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.