I have 2 classes:
Quote:
Class FruitShop
{
int FruitShopId;
string FruitShopName;
IList<Fruit> Fruits {ge;set;}
}
class Fruit
{
int FruitID {get; set;}
string FruitName {get; set;}
bool IsSweet {get; set;}
}
How can I write an expression to return from FruitShop Table, all records, that have a record existing in Fruits with Name "Mango"
I.e.
Return all FruitShop
where FruitShop.Fruits.
contains Any Fruit
where Fruit.FruitName = "Mango"
How can I write an Nhibernate ICreterion for this and what should be the restriction ? something like
ICriteria criteria = CreateCriteria();
...
criteria.Add(restrictions.Eq(x=> x.Fruits.???, ???));
Quote:
As a note,
If I had to check for a FruitshopID 123, I would have written:
criteria.Add(restrictions.Eq(x=> x.FruitShopId, "123"));