c# - Is there any way to delay- execute a delegate against an IQueryable<T> after/during execution? -


I expose an IQueryable method from my business layer for use in other layers to execute the below-level query After this, I want to execute the function against each item in the countdown.

It seems that there should be an event raised after the execution of the query, so that I can work on the results from this normal layer.

Something like this:

  Public IQueryable & lt; Users & gt; Query () {Return _RepositoryQLF & lt; Users & gt; (). ForEachDelayed (u = & gt; Uplandata (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 representative.

Is there something like this? If not, is there an event like "IQueryable.OnExecute" which I can subscribe to?

Any help will be awesome - thanks! Edit

I thought I had the answer:

Users & gt; () Select AppendData (u); Return user;

But now, I get the following error:

The method 'the sendendus (user)' does not have any supported translations in SQL.

After execution of the query, I really need a representative to run.

the easy way

Another option which is easy to add You will need to use the Iterator , see the examples given below. The downside of this approach is that everything is pulled into memory, while recursion is done so that AppendData can only be executed on recorded data. This is similar to the option by @Chris but every time you want to use the method, you are not forced to create a new Func and Select query is.

Fixed zero main (string [] args) {var data = new list & lt; Int & gt; {1, 2, 3, 4, 5} .asQueryable (). AppendData (); Console "Written" ("before executing"); Console Type ("{"); Foreach (var x) in the console console. Type ("{0},", x); Console "Line" ("}"); Console.light line ("after execution"); Console.Read (); } // Add additional data Everything at this point in memory is / should be normal, i.e. AppendData & lt; T & gt ;, but I'm stable IEnumerable & lt; Int & gt; There is an easy way to "add". The attendance (this IEnumerable & lt; int & gt; data) {Console.WriteLine ("add"); Foreign currency (X in data) yield returns x * 2; }

The Hard Path

I do not believe that any such event has been created, but perhaps you have your own IQueryable the cover.

A complete IQueryable provider is a series of writing, which will also show you that you can fit in your cover, which is IQueryProvider .

Good luck and hope that it helps.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -