现在我有一个FilterDefinition:
public class PurposeFilter:FilterDefinition
{
public PurposeFilter()
: base(NHibernateFilters.PurposeFilter, "PurposeId = :purposeId",
new Dictionary<string, IType> { { "purposeId", NHibernateUtil.Int64 } }, false)
{}
}
这会为生成的SQL添加WHERE PurposeId = <someId>
。但是,我想添加对多个ID的支持,因此生成的SQL将是WHERE PurposeId IN (<someId>, <someOtherId>)
。我有以下代码(不起作用) - 关于如何支持这个的任何建议?
public class MultiPurposeFilter : FilterDefinition
{
public MultiPurposeFilter()
: base(NHibernateFilters.MultiPurposeFilter, "PurposeId IN (purposeIds)"
, new Dictionary<string, IType> { { "purposeIds", NHibernateUtil.Int64 } }, false)
{
}
}
答案 0 :(得分:1)
我还没有尝试过,但您可以使用PurposeId IN (:purposeIds)
和SetParameterList
方法设置值。