I want to write a generic extension method that will return a specified set of objects, according to a user-defined filter, with a signature like so:
public static IEnumerable<T> GetObjects<T>(this ObjectSet<T> os, string fieldName, object value) where T : EntityObject {}
Of course, we could change the signature to handle multiple filters, but let’s first focus on the single field filter.
How would you write a Linq query that does this?
You need to dynamically build lambda-expression and call
Queryable.Wherefor os with this expression: