I have 2 classes
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;}
int FruitShopId {get; set;}
}
I want to 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.???, ???));
Fruitshop maps to Fruitshop table and Fruits maps to Fruits table. Fruits contains Foreign key of FruitshopId.