Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# NHibernate,其中使用别名的限制_C#_Nhibernate_Queryover - Fatal编程技术网

C# NHibernate,其中使用别名的限制

C# NHibernate,其中使用别名的限制,c#,nhibernate,queryover,C#,Nhibernate,Queryover,我试图在someProperty.contains(string)| | otherProperty.contains(string)中执行一个查询,因此我发现以下内容: .where( restrictions.on<type>(x => x.property).IsLike(string) || restrictions.on<type>(x => x.prop2).IsLike(string) ) 如何合并此别名?这是上面使用的.On()的语法:

我试图在
someProperty.contains(string)| | otherProperty.contains(string)
中执行一个查询,因此我发现以下内容:

.where(
 restrictions.on<type>(x => x.property).IsLike(string) ||
 restrictions.on<type>(x => x.prop2).IsLike(string)
)

如何合并此别名?

这是上面使用的
.On()
的语法:

/// <summary>
/// Build an ICriterion for the given property
/// </summary>
/// <param name="expression">lambda expression identifying property</param>
/// <returns>returns LambdaRestrictionBuilder</returns>
public static LambdaRestrictionBuilder On<T>(Expression<Func<T, object>> expression)
{
    ExpressionProcessor.ProjectionInfo projection = ExpressionProcessor.FindMemberProjection(expression.Body);
    return new LambdaRestrictionBuilder(projection);
}
//
///为给定属性构建ICriterion
/// 
///lambda表达式标识属性
///返回LambdaRestrictionBuilder
上的公共静态LambdaRestrictionBuilder(表达式)
{
ExpressionProcessor.ProjectionInfo projection=ExpressionProcessor.FindMemberProjection(expression.Body);
返回新的LambdaRestrictionBuilder(投影);
}
这给了我们答案:

传递的表达式必须有一个参数(不必使用)

有效的语法可能如下所示:

// no argument - it is wrong
// Restrictions.On<TradeType>(() => ttypeAlias.TradeTypeName)...

// here we expect one argument, and naming his lo-dash - is convention to say
// it won't be used, it is there just to fulfill all the rules
Restrictions.On<TradeType>(_ => ttypeAlias.TradeTypeName)...
//没有参数-它是错误的
//限制(()=>ttypeAlias.TradeTypeName)。。。
//在这里,我们期待一个论点,命名他的lo dash是惯例
//它不会被使用,它只是为了满足所有的规则
限制(=>ttypeAlias.TradeTypeName)。。。
/// <summary>
/// Build an ICriterion for the given property
/// </summary>
/// <param name="expression">lambda expression identifying property</param>
/// <returns>returns LambdaRestrictionBuilder</returns>
public static LambdaRestrictionBuilder On<T>(Expression<Func<T, object>> expression)
{
    ExpressionProcessor.ProjectionInfo projection = ExpressionProcessor.FindMemberProjection(expression.Body);
    return new LambdaRestrictionBuilder(projection);
}
// no argument - it is wrong
// Restrictions.On<TradeType>(() => ttypeAlias.TradeTypeName)...

// here we expect one argument, and naming his lo-dash - is convention to say
// it won't be used, it is there just to fulfill all the rules
Restrictions.On<TradeType>(_ => ttypeAlias.TradeTypeName)...