本文整理汇总了C#中System.Linq.Expressions.Expression.ChangeOperands方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.ChangeOperands方法的具体用法?C# Expression.ChangeOperands怎么用?C# Expression.ChangeOperands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Expression
的用法示例。
在下文中一共展示了Expression.ChangeOperands方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalyzeOperands
protected virtual Expression AnalyzeOperands(Expression expression, TranslationContext context)
{
var operands = expression.GetOperands().ToList();
var newOperands = new List<Expression>();
for (int operandIndex = 0; operandIndex < operands.Count; operandIndex++)
{
var op = operands[operandIndex];
var newOp = Analyze(op, context);
newOperands.Add(newOp);
}
return expression.ChangeOperands(newOperands, operands);
}
示例2: CutOutOperands
/// <summary>
/// Cuts tiers in CLR / SQL.
/// The search for cut is top-down
/// </summary>
/// <param name="expression"></param>
/// <param name="dataRecordParameter"></param>
/// <param name="mappingContextParameter"></param>
/// <param name="builderContext"></param>
/// <returns></returns>
protected virtual Expression CutOutOperands(Expression expression,
ParameterExpression dataRecordParameter, ParameterExpression mappingContextParameter,
BuilderContext builderContext)
{
// two options: we cut and return
if (GetCutOutOperand(expression, builderContext))
{
// "cutting out" means we replace the current expression by a SQL result reader
// before cutting out, we check that we're not cutting a table
// in this case, we convert it into its declared columns
if (expression is TableExpression)
{
return GetOutputTableReader((TableExpression)expression, dataRecordParameter,
mappingContextParameter, builderContext);
}
// for EntitySets, we have a special EntitySet builder
if (expression is EntitySetExpression)
{
return GetEntitySetBuilder((EntitySetExpression) expression, dataRecordParameter,
mappingContextParameter, builderContext);
// TODO record EntitySet information, so we can initalize it with owner
}
// then, the result is registered
return GetOutputValueReader(expression, dataRecordParameter, mappingContextParameter, builderContext);
}
// or we dig down
var operands = new List<Expression>();
foreach (var operand in expression.GetOperands())
{
operands.Add(operand == null
? null
: CutOutOperands(operand, dataRecordParameter, mappingContextParameter, builderContext));
}
return expression.ChangeOperands(operands);
}
示例3: CutOutSqlTier
protected virtual Expression CutOutSqlTier(Expression expression,
ParameterExpression dataRecordParameter, ParameterExpression sessionParameter,
Type expectedType,
TranslationContext context)
{
expectedType = expectedType ?? expression.Type;
// two options: we cut and return
if (IsSqlTier(expression, context))
{
// "cutting out" means we replace the current expression by a SQL result reader
// before cutting out, we check that we're not cutting a table in this case, we convert it into its declared columns
if (expression is TableExpression)
// RI: entity reader comes here
return GetOutputTableReader((TableExpression)expression, dataRecordParameter,
sessionParameter, context);
// RI: single-value result goes here
return GetOutputValueReader(expression, expectedType, dataRecordParameter, sessionParameter, context);
}
// RI: Anon types, custom types go here
var newOperands = new List<Expression>();
var operands = expression.GetOperands();
var argTypes = expression.GetArgumentTypes();
for(int i = 0; i < operands.Count; i++ ) {
var op = operands[i];
var newOp = op == null ? null : CutOutSqlTier(op, dataRecordParameter, sessionParameter, argTypes[i], context);
newOperands.Add(newOp);
}
Expression newExpr;
if (expression is MetaTableExpression)
//Joins go here
newExpr = ((MetaTableExpression)expression).ConvertToNew(newOperands);
else
newExpr = expression.ChangeOperands(newOperands, operands);
return newExpr;
}