本文整理汇总了C#中System.Linq.Expressions.Expression.NiceToString方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.NiceToString方法的具体用法?C# Expression.NiceToString怎么用?C# Expression.NiceToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Expression
的用法示例。
在下文中一共展示了Expression.NiceToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEntity
private static Expression GetEntity(Expression exp)
{
exp = ConstantToLite(exp) ?? exp;
if (exp.IsNull())
return Expression.Constant(null, exp.Type.CleanType());
var liteExp = exp as LiteReferenceExpression;
if (liteExp == null)
throw new InvalidCastException("Impossible to convert expression to Lite: {0}".Formato(exp.NiceToString()));
return liteExp.Reference;
}
示例2: TypeIn
internal static Expression TypeIn(Expression typeExpr, IEnumerable<Type> collection)
{
if (collection.IsNullOrEmpty())
return False;
if (typeExpr.NodeType == ExpressionType.Conditional)
return DispachConditionalTypesIn((ConditionalExpression)typeExpr, collection);
if (typeExpr.NodeType == ExpressionType.Constant)
{
Type type = (Type)((ConstantExpression)typeExpr).Value;
return collection.Contains(type) ? True : False;
}
if (typeExpr.NodeType == (ExpressionType)DbExpressionType.TypeEntity)
{
var typeFie = (TypeEntityExpression)typeExpr;
return collection.Contains(typeFie.TypeValue) ? NotEqualToNull(typeFie.ExternalId) : (Expression)False;
}
if (typeExpr.NodeType == (ExpressionType)DbExpressionType.TypeImplementedBy)
{
var typeIb = (TypeImplementedByExpression)typeExpr;
return typeIb.TypeImplementations.Where(imp => collection.Contains(imp.Key))
.Select(imp => NotEqualToNull(imp.Value)).AggregateOr();
}
if (typeExpr.NodeType == (ExpressionType)DbExpressionType.TypeImplementedByAll)
{
var typeIba = (TypeImplementedByAllExpression)typeExpr;
object[] ids = collection.Select(t => (object)QueryBinder.TypeId(t)).ToArray();
return In(typeIba.TypeColumn, ids);
}
throw new InvalidOperationException("Impossible to resolve '{0}' in '{1}'".Formato(typeExpr.NiceToString(), collection.ToString(t=>t.TypeName(), ", ")));
}
示例3: Visit
protected override Expression Visit(Expression exp)
{
switch (exp.NodeType)
{
case ExpressionType.Conditional:
case ExpressionType.Constant:
case ExpressionType.Parameter:
case ExpressionType.Call:
case ExpressionType.Lambda:
case ExpressionType.New:
case ExpressionType.NewArrayInit:
case ExpressionType.NewArrayBounds:
case ExpressionType.Invoke:
case ExpressionType.MemberInit:
case ExpressionType.ListInit:
throw new NotSupportedException("Expression of type {0} not supported: {1}".Formato(exp.NodeType, exp.NiceToString()));
default:
return base.Visit(exp);
}
}
示例4: TypeEquals
private static Expression TypeEquals(Expression exp1, Expression exp2)
{
if (exp1.Type != typeof(Type) || exp2.Type != typeof(Type))
return null;
if (exp1.NodeType == ExpressionType.Constant)
{
if (exp2.NodeType == ExpressionType.Constant) return TypeConstantConstantEquals((ConstantExpression)exp1, (ConstantExpression)exp2);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeEntity) return TypeConstantFieEquals((ConstantExpression)exp1, (TypeEntityExpression)exp2);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeImplementedBy) return TypeConstantIbEquals((ConstantExpression)exp1, (TypeImplementedByExpression)exp2);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeImplementedByAll) return TypeConstantIbaEquals((ConstantExpression)exp1, (TypeImplementedByAllExpression)exp2);
}
else if (exp1.NodeType == (ExpressionType)DbExpressionType.TypeEntity)
{
if (exp2.NodeType == ExpressionType.Constant) return TypeConstantFieEquals((ConstantExpression)exp2, (TypeEntityExpression)exp1);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeEntity) return TypeFieFieEquals((TypeEntityExpression)exp1, (TypeEntityExpression)exp2);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeImplementedBy) return TypeFieIbEquals((TypeEntityExpression)exp1, (TypeImplementedByExpression)exp2);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeImplementedByAll) return TypeFieIbaEquals((TypeEntityExpression)exp1, (TypeImplementedByAllExpression)exp2);
}
else if (exp1.NodeType == (ExpressionType)DbExpressionType.TypeImplementedBy)
{
if (exp2.NodeType == ExpressionType.Constant) return TypeConstantIbEquals((ConstantExpression)exp2, (TypeImplementedByExpression)exp1);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeEntity) return TypeFieIbEquals((TypeEntityExpression)exp2, (TypeImplementedByExpression)exp1);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeImplementedBy) return TypeIbIbEquals((TypeImplementedByExpression)exp1, (TypeImplementedByExpression)exp2);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeImplementedByAll) return TypeIbIbaEquals((TypeImplementedByExpression)exp1, (TypeImplementedByAllExpression)exp2);
}
else if (exp1.NodeType == (ExpressionType)DbExpressionType.TypeImplementedByAll)
{
if (exp2.NodeType == ExpressionType.Constant) return TypeConstantIbaEquals((ConstantExpression)exp2, (TypeImplementedByAllExpression)exp1);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeEntity) return TypeFieIbaEquals((TypeEntityExpression)exp2, (TypeImplementedByAllExpression)exp1);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeImplementedBy) return TypeIbIbaEquals((TypeImplementedByExpression)exp2, (TypeImplementedByAllExpression)exp1);
else if (exp2.NodeType == (ExpressionType)DbExpressionType.TypeImplementedByAll) return TypeIbaIbaEquals((TypeImplementedByAllExpression)exp1, (TypeImplementedByAllExpression)exp2);
}
throw new InvalidOperationException("Impossible to resolve '{0}' equals '{1}'".Formato(exp1.NiceToString(), exp2.NiceToString()));
}
示例5: InvalidSqlExpression
private InvalidOperationException InvalidSqlExpression(Expression expression)
{
return new InvalidOperationException("Unexepected expression on sql {0}".Formato(expression.NiceToString()));
}