本文整理汇总了C#中SearchCriteria.EnumerateSubCriteria方法的典型用法代码示例。如果您正苦于以下问题:C# SearchCriteria.EnumerateSubCriteria方法的具体用法?C# SearchCriteria.EnumerateSubCriteria怎么用?C# SearchCriteria.EnumerateSubCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchCriteria
的用法示例。
在下文中一共展示了SearchCriteria.EnumerateSubCriteria方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromSearchCriteria
/// <summary>
/// Extracts a list of <see cref="HqlCondition"/> objects from the specified <see cref="SearchCriteria"/>
/// </summary>
/// <param name="qualifier">The HQL qualifier to prepend to the criteria variables</param>
/// <param name="criteria">The search criteria object</param>
/// <param name="remapHqlExprFunc"></param>
/// <returns>A list of HQL conditions that are equivalent to the search criteria</returns>
public static HqlCondition[] FromSearchCriteria(string qualifier, SearchCriteria criteria, Converter<string, string> remapHqlExprFunc)
{
var hqlConditions = new List<HqlCondition>();
if (criteria is SearchConditionBase)
{
var sc = (SearchConditionBase)criteria;
if (sc.Test != SearchConditionTest.None)
{
hqlConditions.Add(GetCondition(remapHqlExprFunc(qualifier), sc.Test, sc.Values));
}
}
else
{
// recur on subCriteria
foreach (var subCriteria in criteria.EnumerateSubCriteria())
{
// use a different syntax for "extended properties" than regular properties
var subQualifier = criteria is ExtendedPropertiesSearchCriteria ?
string.Format("{0}['{1}']", qualifier, subCriteria.GetKey()) :
string.Format("{0}.{1}", qualifier, subCriteria.GetKey());
hqlConditions.AddRange(FromSearchCriteria(subQualifier, subCriteria, remapHqlExprFunc));
}
}
return hqlConditions.ToArray();
}