Hi Chaps,
Hopefully someone can help me out :)
I have an object with a collection of objects as a property, so lets say:
Code:
class ContainerObject
{
public int Id;
public IList<InnerObject> InnerObjects;
}
class InnerObject
{
public int Id;
}
I'm trying to write a criteria query to return ContainerObjects where the collection of InnerObjects is empty or contains an InnerObject with id of 1.
I can do the parts of this query individually:
Empty CollectionCode:
IList containerObjects = sess.CreateCriteria(typeof(ContainerObject))
.Add( Expression.IsEmpty( "InnerObjects" ) )
.List();
Id in collectionCode:
IList containerObjects = sess.CreateCriteria(typeof(ContainerObject))
.CreateCriteria( "InnerObjects" )
.Add( Expression.Eq( "Id", 1 ) )
.List();
I don't know how to do both parts in an
OR so either the collection is empty or it contains an object with id of 1.
Can anyone help?
Thanks muchly