當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。