Here are my relevant classes:
public class Item {
public virtual int Id { get; protected set; }
public virtual IList<Tag> Tags { get; set; }
}
public class Tags {
public virtual int Id { get; protected set; }
public virtual string Name { get; set; }
public virtual IList<Item> Items { get; set; }
}
These are mapped with a many to many association. The intermediate table is named ItemsToTags.
Here's the question:
Given a list of strings, how do I create an NHibernate query that returns all
Item
s that have all theTag
s withName
s matching all the strings in the given list?
This is the function signature:
IList<Item> GetItemsWithTags(IList<string> tagNames);
I need something like:
from Item item
where !tagsNames.Except(
from item.Tags select item.Tags.Name
).Any()
select item
Thanks in advance for any help.