当前位置: 首页>>代码示例>>C#>>正文


C# Expression.NiceToString方法代码示例

本文整理汇总了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; 
        }
开发者ID:nuub666,项目名称:framework,代码行数:13,代码来源:SmartEqualizer.cs

示例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(), ", ")));
        }
开发者ID:nuub666,项目名称:framework,代码行数:41,代码来源:SmartEqualizer.cs

示例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);
     }
 }
开发者ID:nuub666,项目名称:framework,代码行数:20,代码来源:UniqueIndex.cs

示例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()));
        }
开发者ID:nuub666,项目名称:framework,代码行数:36,代码来源:SmartEqualizer.cs

示例5: InvalidSqlExpression

 private InvalidOperationException InvalidSqlExpression(Expression expression)
 {
     return new InvalidOperationException("Unexepected expression on sql {0}".Formato(expression.NiceToString()));
 }
开发者ID:nuub666,项目名称:framework,代码行数:4,代码来源:QueryFormatter.cs


注:本文中的System.Linq.Expressions.Expression.NiceToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。