I recently got "caught" by something I didn't know in LLBLGen .. namely that Predicates obtained through a call to GetEntityTypeFilter() do not work for in-memory filtering of collections or creation of entity views etc.
This was my fault I guess .. I had used GetEntityTypeFilter() successfully for DB fetches and just assumed that this also worked in-memory ... ooops!
I found the answer on this forum and THEN found the note in the docs but didn't see this anywhere when reading the docs (which may be my fault). Might I suggest making specific cross reference to this aspect in the section on creating entity views or filtering collections etc as well as in the section to help lazy people like me ;-)
Also, I am wondering if the wording on the Filtering on Entity Type section should be a little stronger ... specifically, that GetEntityTypeFilter() will not work on in-memory collections.
Now, the correct solution works beautifully of course .. namely, using the DelegatePredicate to test assignability. I'll repeat the solution here in case anyone finds this thread when searching for an answer ...
// Create a Predicate for filtering in-memory collections etc
// Replace _entity type to filter_ with the type you want found
IPredicateExpression checkEntryFilter = new PredicateExpression(
new DelegatePredicate(
delegate(IEntityCore toExamine) {
return (typeof(_entity type to filter_).IsAssignableFrom(toExamine.GetType()));
}));
However, I do miss the convenience of using MyEntity.GetEntityTypeFilter() and I find myself reproducing the code snippet above quite often ... so I was wondering how I can automatically create a new method for each generated entity type like GetInMemoryTypeFilter().
I figure that it would be possible to add something to the code generation templates but I have never touched this side of things and I was hoping someone might be able to show me how to do this.
Is this a good idea or is there a better way of doing this using partial classes or something?
Thanks for the great documentation - I am not meaning to infer that it is lacking at all ... just that I know I tended to learn LLBLGen in bits and pieces when I first came to it and this is a bit of a "gotcha" because you only find out at runtime that you've goofed ;-)
Thanks for your help in advance :-)