views:

185

answers:

1

Looking for direction and understanding of the approach to implement logic to handle the scenario below, if possible with LINQ-to-Entities. New to LINQ and Entity Framework, but understand the basics. Intermediate with C#.

I have a function, which needs to iterate through and add information to a results set and ultimately pass back the "processed" result set. I'd like to be able call this function in an inline/Lambda/method based way with the LINQ query that retrieves the data. So something like this:


    IQueryable<Rates> = db.Rates.Select(r => r).ProcessRates();

So what LINQ/C# construct am I going to employ to implement the function? Would it be an extension method or ???

Answers with explanation and code snippets will be greatly appreciated, especially the syntax necessary to create the function properly.

+2  A: 

Yes this would require an extension method on IEnumerable<Rates>.

Something like this ought to work:

public static IQueryable<Rates> ProcessRates(this IEnumerable<Rates> rates)
{
 foreach (Rates r in rates)
  r.Process();

 return rates.AsQueryable();
}
Andrew Hare
Andrew many thanks!!!
Carter