I have a class with a number of fields, one being an IList<KeyValuePair<string, string>>
.
public class Foo
{
public IList<KeyValuePair<string, string>> Bars { get; set; }
}
I'm using Fluent NHibernate and that particular field is mapped as follows:
HasMany(x => x.Bars).Component(Bar.Map);
and
public class BarMap : ComponentMap<KeyValuePair<string, string>>
{
public BarMap()
{
Map(x => x.Key);
Map(x => x.Value);
}
public static void Map(CompositeElementPart<KeyValuePair<string, string>> part)
{
part.Map(x => x.Key);
part.Map(x => x.Value);
}
}
Using the ICriteria API, I would like to be able to select all Foo where Bars contains a key value pair { X, Y }
, and for the matching of X and Y values to be case insensitive. How can I do this?
The way how to query IDictionary is in detail described here
and documented here
Description Syntax Example
A collection key {[aliasname].key} ORGID as {coll.key}
The id of an collection {[aliasname].id} EMPID as {coll.id}
The element of an collection {[aliasname].element} XID as {coll.element}
So, we can do something like this
.Add(Restrictions.Eq("Bars.elements", searchedValue));