我必须简单的实体
public class EntityA
{
public virtual int ID { get;set;}
public virtual string Name { get;set;}
public virtual IList<EntityB> BList { get;set;}
public EntityA()
{
BLIst = new List<EntityB>();
}
}
public class EntityB
{
public virtual int ID { get;set;}
public virtual string Name { get;set;}
public virtual int Value { get;set;}
public virtual EntityA EntityA { get;set;}
}
我如何进行 ICriteria 查询,其中应该查询 EntityA.Name = 'SearchString' 和 List (((EntityB.Name='Name1' And (EntityB.Value=1)) And ((EntityB.Name='Name2')和 (EntityB.Value=1)))
搜索可以包含一个列表,我尝试了以下查询:
if (SearchBLIst.Count > 0)
{
foreach (EntityB searchAttribute in SearchBLIst)
{
Junction disjunction1 = Restrictions.Disjunction();
disjunction1.Add(
Expression.Eq("entityB.ID", searchAttribute.ID) &&
Expression.Ge("attributeValues.Value",searchAttribute.value));
store.Add(disjunction1);
}
}