I'm trying to filter by a list of values using the criteria API. I suspect that this is not possible, I'm just asking here to be sure.
class Entity
{
int id { get; set; }
IList<Guid> Guids { get; set; }
}
The mapping:
<class name="Entity">
<id ...></id>
<bag name="Guids" table="Entity_Guids">
<key column="Entity_FK"/>
<element column="Guid"/>
</bag>
</class>
Assumed I have a list of Guids (actually these is another subquery). I want to filter all Entities where at least one guid is in the list of Guids.
Sql would look like this:
SELECT *
FROM Entity e
inner join Entity_Guids eg
on e.id = eg.Entity_FK
WHERE
eg.Guid in (subquery)
With Criteria API, this seems to be impossible.
ICriteria query = session
.CreateCriteria(typeof(Entity), "e")
.Add(Subqueries.In("e.Guids", subquery))
Throws an exception.