The lambda for Where needs to take the entity type; I would expect that you would need: interface IEntity where T : class { Expression> FilterQuery(string filter); } partial class AnEntity : IEntity { public string AName {get; set;} Expression> IEntity. FilterQuery(string filter) { return x => x.AName. Contains(filter); } } However; the FilterQuery method doesn't feel like an entity responsibility... (separation of concerns); which is why it isn't helpful in the "list" case; maybe you need to move that to the list?
But when it works, something like: T template = new T(); // this is a horrible way to get the filter! // and illustrates that this method doesn't belong on // this type; only done this way to fit the question's // pretext - which I believe is... suboptimal. Var filterQuery = template.
FilterQuery(filter); items = items. Where(filterQuery).
Thanks Marc... That's a good solution, but I see what you mean about 'suboptimal'... I'll add a comment to rephrase the question, see if there is a better way to achieve what I want. – stew Sep 30 '09 at 8:56 I'm really just talking about roles; the method to filter instances of type A doesn't really sit well as an instance method of type A. It would work on the repository for the type, or as a static method on the type (but static methods can't participate in interfaces, of course).
– Marc Gravell? Sep 30 '09 at 11:00 Yes, I would have preferred a static method... but couldn't use one for the exact reason you describe. – stew Sep 30 '09 at 11:49.
Use an ORM that is widely used and vetted, and you'll save yourself A TON of pain.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.