本文整理汇总了C#中System.Linq.Expressions.Expression.First方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.First方法的具体用法?C# Expression.First怎么用?C# Expression.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Expression
的用法示例。
在下文中一共展示了Expression.First方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeWhereMethod
private static Expression MakeWhereMethod(Expression context, Expression argContext, string methodName, Expression[] args)
{
ExpectArgsCount(1, args, methodName);
var predicate = args.First();
ExpectArgTypeToBe(predicate.Type, typeof(bool), methodName);
var lambda = Expression.Lambda(predicate, argContext as ParameterExpression);
return ExpressionUtil.MakeExpressionCall(new []{typeof(Queryable), typeof(Enumerable)}, "Where", new Type[] {argContext.Type}, context, lambda);
}
示例2: MakeOrderByMethod
private static Expression MakeOrderByMethod(Expression context, Expression argContext, string methodName, Expression[] args)
{
ExpectArgsCount(1, args, methodName);
var column = args.First();
var lambda = Expression.Lambda(column, argContext as ParameterExpression);
return ExpressionUtil.MakeExpressionCall(new []{typeof(Queryable), typeof(Enumerable)}, "OrderBy", new Type[] {argContext.Type, column.Type}, context, lambda);
}
示例3: MakeTakeMethod
private static Expression MakeTakeMethod(Expression context, Expression argContext, string methodName, Expression[] args)
{
ExpectArgsCount(1, args, methodName);
var amount = args.First();
ExpectArgTypeToBe(amount.Type, typeof(int), methodName);
return ExpressionUtil.MakeExpressionCall(new []{typeof(Queryable), typeof(Enumerable)}, "Take", new Type[] {argContext.Type}, context, amount);
}
示例4: MakeOptionalFilterArgumentCall
private static Expression MakeOptionalFilterArgumentCall(Expression context, Expression argContext, string methodName, Expression[] args, string actualMethodName)
{
ExpectArgsCountBetween(0, 1, args, methodName);
var allArgs = new List<Expression> { context };
if (args.Count() == 1) {
var predicate = args.First();
ExpectArgTypeToBe(predicate.Type, typeof(bool), methodName);
allArgs.Add(Expression.Lambda(predicate, argContext as ParameterExpression));
}
return ExpressionUtil.MakeExpressionCall(new []{typeof(Queryable), typeof(Enumerable)}, actualMethodName, new Type[] {argContext.Type}, allArgs.ToArray());
}