Nhibernate cannot use the sql query IDictionary<long, IAttributeValue> because IAttributeValue does not appear in hbm as an entity.
But I solved this problem.
I replaced the display of one IDictionary with three simpler ones:
<map name="StringValues" table="ALL_ATM_DEV_SATTRIB_VALS" lazy="true" fetch="select"> <key column="DEVICE_ID" /> <index column="ATTRIB_ID" type="System.Int64" /> <element column="STRING_VALUE" type="System.String"/> </map> <map name="DateValues" table="ALL_ATM_DEV_SATTRIB_VALS" lazy="true" fetch="select"> <key column="DEVICE_ID" /> <index column="ATTRIB_ID" type="System.Int64" /> <element column="DATE_VALUE" type="System.DateTime"/> </map> <map name="IntValues" table="ALL_ATM_DEV_SATTRIB_VALS" lazy="true" fetch="select"> <key column="DEVICE_ID" /> <index column="ATTRIB_ID" type="System.Int64" /> <element column="INT_VALUE" type="System.Int64"/> </map>
I use these cards only to create a sql query for the result , so lazy=true present, and never access them in the IDevice
The data from these maps immediately chose another sql query, because lazy initialization will cause n + 1 sql-query in the database.
The Linq query in my question is converted to:
List<IDevice> a = dc.Get<IDevice>() .Where(x=>x.StringValues[13].ToLower().Contains("10.0.3")) .ToList();
Three maps are defined in an IDevice entity:
public virtual IDictionary<long, long> IntValues { get; set; } public virtual IDictionary<long, string> StringValues { get; set; } public virtual IDictionary<long, DateTime> DateValues { get; set; }
source share