我有这个代码:
if (pertinentDataExists) {
List<Entity> operatorList = new List<Operator>();
List<Entity> newOperatorList = criteria.newOperatorList;
foreach (Operator operator in operatorList)
{
operatorList.Add(operator);
}
queryCriteria.CreateCriteria("OperatorList").Add(Restrictions.In("Operator", operatorList));
}
然后:
if (otherPertinentDataExists) {
Object[] objects = new Object[criteria.newRoleTypeList.Count];
for (int = 0; i < criteria.RoleTypeList.Count; i++) {
objects[i] = criteria.RoleTypeList[i].Id;
}
queryCriteria.CreateCriteria("OperatorList").Add(Restrictions.In("Role", objects));
}
这些单独工作就好了。但是,如果这两种情况都有要添加到列表中的标准,那么我会得到:
NHibernate.QueryException 消息:重复关联路径:OperatorList
Role
如果已创建条件,如何添加限制?