I have no idea if this is possible ... but it would be cool. the question is whether it is possible but then a bit of an example if possible.
I am not sure what method signature you would use to pass the lambda expression into.
Eg the method IList<Group> GetGroups()
How would you modify that to be able to pass a lambda expression into it?
The next question is how would you code a lambda expression to return all Group objects where for example
where .deleted == false
orwhere .DateAdded > aDate
Yeah, I want the moon on a stick ;) Thanks in advance.
(edit I am thinking this is a bit ill-conceived actually because of the data access layer that would actually fetch the data ... but assume that you are querying some object collection over the service and don't have to worry about the dal).
You could declare the GetGroups
method with a parameter of type Expression<Func<Group, bool>>
, which represents a predicate that the group must match in order to be returned :
IList<Group> GetGroups(Expression<Func<Group, bool>> predicateExpression);
The trouble is, expressions can't be serialized, so you couldn't send it to the WCF service... However, you might find a way to do it with the Expression Tree Serialization project.
You could
Matt Warren has seventeen blog articles about how to do this sort of thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With