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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:33:41+00:00 2026-05-13T17:33:41+00:00

I expose an IQueryable method from my business layer for use in other layers.

  • 0

I expose an IQueryable method from my business layer for use in other layers. I would like to execute a function against each of the items in the enumeration, once the query has executed down-level.

It seems like there should be an event that is raised after the query executes, so that I can then operate on the results from this common layer.

Something like:

public IQueryable<User> Query() 
{
    return _Repository.Query<User>().ForEachDelayed(u=> AppendData(u));
}

I want the ForEachDelayed function to return the IQueryable without executing the query. The idea is, once the query is executed, the results are passed through this delegate.

Is there something like this out there? If not, is there an event like “IQueryable.OnExecute” that I can subscribe to?

Any help would be awesome — thanks!

EDIT:

I thought I had the answer with this:

var users = from u in _Repository.Query<User>()
            select AppendData(u);
return users;

But now, I get the following error:

Method ‘AppendData(User)’ has no supported translation to SQL.

I really need a delegate to run AFTER the query has executed.

  • 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-13T17:33:42+00:00Added an answer on May 13, 2026 at 5:33 pm

    The Easy Way

    Another option that is much simpler would be to append what you need using an Iterator, see the example below. The downside of this approach is that everything would have been pulled into memory while the iteration is performed so that AppendData is only executed on the returned data. This is similar to the option by @Chris but you are not forced to create a new Func and Select query every time you want to use the method.

    static void Main(string[] args)
    {
        var data = new List<int> { 1, 2, 3, 4, 5 }.AsQueryable().AppendData();
    
        Console.WriteLine("Before execute");
    
        Console.Write("{ ");
        foreach (var x in data)
           Console.Write("{0}, ", x);
    
        Console.WriteLine( "}");
    
        Console.WriteLine("After execute");
    
        Console.Read();
    }
    
    // Append extra data. From this point on everything is in memory
    // This should be generic, i.e. AppendData<T>, but I an easy way to "append"
    static IEnumerable<int> AppendData(this IEnumerable<int> data)
    {
        Console.WriteLine("Adding");
        foreach (var x in data)            
            yield return x * 2;
    }
    

    The Hard Way

    I do not believe there are any built in events like this but you could probably add your own by implementing your own IQueryable wrapper.

    Here is a series on writing a complete IQueryable provider which will also show you where you could fit your wrapper, most likely around that IQueryProvider.

    Good luck and Hope this helps.

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

Sidebar

Related Questions

How to list all registered users from a RIA Service? I tried to expose
If you return IList(T) from your repository ... How could you efficiently create SQL
I've been learning about IQueryable and lazy loading/deferred execution of queries. Is it possible
I am trying to expose an editable Azure Table Storage table. (If it matters:
How expose a enum that is not in any operation? Can i do this
I need to expose a web API to an iPhone app. Users will connect
In my Custom ObjectContext class I have my entity collections exposed as IObjectSet so
I have a 'Customer' POCO entity within my Entity Framework 4 project. I want
I want to offer my users a rich query functionality so they can dynamically
This may be duplicate question but I could not find one on SO. If

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.