I’m trying to map a Dictionary containing Lists.
I have the following set of tables:
CREATE TABLE Item(id)
CREATE TABLE Filter(id)
CREATE TABLE FilterType(id)
CREATE TABLE ItemFilter(
item REFERENCES Item(id),
filter REFERENCES Filter(id),
filterType REFERENCES FilterType(id)
)
and I want to do this mapping:
class Item{
public IDictionary<long, IList<ItemFilter>> ItemFiltersByType;
}
The long is the id of the filterType.
I was using this mapping but its not working:
Any help would be appreciated : P.
Tks
I don’t think you can do what you’re trying to do here. The closest available mapping pattern is the ternary association. This is actually what you have but you don’t have a unique index. NHibernate only supports the raw IDictionary interface which does not support multiple values off a single key. If you had a unique index value for FilterType (which, judging by the name, you rightly don’t), you could do:
I think the best solution in this case would be to move the operation to a repository with a method like: