Hi,
I've rammed into a huge problem. I got to these two objects:
IList<Product> products;
and
Collection collection;
Both objects contains and IList<Tag>
named .Tags.
I'm trying to do the this with Linq To NHibernate:
products = products.Where(p => p.Tags.Any(t => collection.Tags.Contains(t)));
This will give an exception, because Linq To NHibernate don't support this. But how can I accomplish this? I just can't find any smart way to only get the products
that contains the tags that the specific collection
has.
Thanks in advance!
Btw, the problem seems very similar to http://stackoverflow.com/questions/2126591/iqueryable-contains-any-of-string-array, but in my scenario I don't want to compare with a string array, but with a collection of poco objects.
[EDIT]
I found out that it throws this exception:
Unable to cast object of type 'System.Linq.Expressions.ConstantExpression' to type 'System.Linq.Expressions.LambdaExpression'.
Alternative ways to resolve the issue is welcome too (HQL etc).
Thanks! [/EDIT]