本文整理汇总了C#中System.Linq.Expressions.Expression.QueryableSelect方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.QueryableSelect方法的具体用法?C# Expression.QueryableSelect怎么用?C# Expression.QueryableSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Expression
的用法示例。
在下文中一共展示了Expression.QueryableSelect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectOpenProperty
private static Expression SelectOpenProperty(Expression queryExpression, string propertyName)
{
ParameterExpression expression = Expression.Parameter(queryExpression.ElementType(), "element");
LambdaExpression selector = Expression.Lambda(Expression.Call(null, OpenTypeMethods.GetValueOpenPropertyMethodInfo, expression, Expression.Constant(propertyName)), new ParameterExpression[] { expression });
return queryExpression.QueryableSelect(selector);
}
示例2: SelectLateBoundProperty
private static Expression SelectLateBoundProperty(Expression queryExpression, ResourceProperty property)
{
ParameterExpression expression = Expression.Parameter(queryExpression.ElementType(), "element");
LambdaExpression selector = Expression.Lambda(Expression.Convert(Expression.Call(null, DataServiceProviderMethods.GetValueMethodInfo, expression, Expression.Constant(property)), property.Type), new ParameterExpression[] { expression });
return queryExpression.QueryableSelect(selector);
}
示例3: SelectElement
private static Expression SelectElement(Expression queryExpression, ResourceProperty property)
{
ParameterExpression expression = Expression.Parameter(queryExpression.ElementType(), "element");
Expression expression2 = Expression.Property(expression, property.Name);
if ((property.TypeKind == ResourceTypeKind.Collection) && (expression2.Type != property.Type))
{
expression2 = Expression.Convert(expression2, property.Type);
}
LambdaExpression selector = Expression.Lambda(expression2, new ParameterExpression[] { expression });
return queryExpression.QueryableSelect(selector);
}
示例4: SelectLateBoundProperty
private static Expression SelectLateBoundProperty(Expression queryExpression, ResourceProperty property)
{
Debug.Assert(queryExpression != null, "queryExpression != null");
Debug.Assert(property != null && !property.CanReflectOnInstanceTypeProperty, "property != null && !property.CanReflectOnInstanceTypeProperty");
ParameterExpression parameter = Expression.Parameter(queryExpression.ElementType(), "element");
Expression body = Expression.Call(null /*instance*/, DataServiceProviderMethods.GetValueMethodInfo, parameter, Expression.Constant(property));
body = Expression.Convert(body, property.Type);
LambdaExpression selector = Expression.Lambda(body, parameter);
return queryExpression.QueryableSelect(selector);
}
示例5: SelectOpenProperty
private static Expression SelectOpenProperty(Expression queryExpression, string propertyName)
{
Debug.Assert(queryExpression != null, "queryExpression != null");
Debug.Assert(propertyName != null, "propertyName != null");
ParameterExpression parameter = Expression.Parameter(queryExpression.ElementType(), "element");
Expression body = Expression.Call(null /* instance */, OpenTypeMethods.GetValueOpenPropertyMethodInfo, parameter, Expression.Constant(propertyName));
LambdaExpression selector = Expression.Lambda(body, parameter);
return queryExpression.QueryableSelect(selector);
}
示例6: SelectElement
private static Expression SelectElement(Expression queryExpression, ResourceProperty property)
{
Debug.Assert(queryExpression != null, "queryExpression != null");
Debug.Assert(property.Kind != ResourcePropertyKind.ResourceSetReference, "property != ResourcePropertyKind.ResourceSetReference");
ParameterExpression parameter = Expression.Parameter(queryExpression.ElementType(), "element");
Expression body = Expression.Property(parameter, property.Name);
// If the property is a collection its instance type is always IEnumerable<T>, but the actual type of the property
// might be type a type implementing the IEnumerable<T> (Like List<T>). We need to add an explicit cast here
// so that our expression types match and we will be able to call the lambda later.
if (property.TypeKind == ResourceTypeKind.Collection && body.Type != property.Type)
{
body = Expression.Convert(body, property.Type);
}
LambdaExpression selector = Expression.Lambda(body, parameter);
return queryExpression.QueryableSelect(selector);
}