• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DbExpressionKind类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DbExpressionKind的典型用法代码示例。如果您正苦于以下问题:C# DbExpressionKind类的具体用法?C# DbExpressionKind怎么用?C# DbExpressionKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DbExpressionKind类属于命名空间,在下文中一共展示了DbExpressionKind类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DbUnaryExpression

        internal DbUnaryExpression(DbExpressionKind kind, TypeUsage resultType, DbExpression argument)
            : base(kind, resultType)
        {
            Debug.Assert(argument != null, "DbUnaryExpression.Argument cannot be null");

            _argument = argument;
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:7,代码来源:DbUnaryExpression.cs


示例2: CreateComparison

        private Expression CreateComparison(Expression left, Expression right, DbExpressionKind kind)
        {
            if (left.Type == typeof(string) && right.Type == typeof(string))
            {
                return CreateStringComparison(left, right, kind);
            }

            switch (kind)
            {
                case DbExpressionKind.Equals:
                    return Expression.Equal(left, right);

                case DbExpressionKind.NotEquals:
                    return Expression.NotEqual(left, right);

                case DbExpressionKind.GreaterThan:
                    return Expression.GreaterThan(left, right);

                case DbExpressionKind.GreaterThanOrEquals:
                    return Expression.GreaterThanOrEqual(left, right);

                case DbExpressionKind.LessThan:
                    return Expression.LessThan(left, right);

                case DbExpressionKind.LessThanOrEquals:
                    return Expression.LessThanOrEqual(left, right);

                default:
                    throw new InvalidOperationException(
                        "The ExpressionKind cannot be " + kind.ToString());
            }
        }
开发者ID:nozerowu,项目名称:ABP,代码行数:32,代码来源:TransformVisitor.Comparison.cs


示例3: GetLeafNodes

        // <summary>
        // Uses a stack to non-recursively traverse a given tree structure and retrieve the leaf nodes.
        // </summary>
        // <param name="root"> The node that represents the root of the tree. </param>
        // <param name="kind"> Expressions not of this kind are considered leaves. </param>
        // <param name="getChildNodes">
        // A function that traverses the tree by retrieving the <b>immediate</b> descendants of a (non-leaf) node.
        // </param>
        // <returns> An enumerable containing the leaf nodes. </returns>
        public static IEnumerable<DbExpression> GetLeafNodes(
            this DbExpression root,
            DbExpressionKind kind,
            Func<DbExpression, IEnumerable<DbExpression>> getChildNodes)
        {
            DebugCheck.NotNull(getChildNodes);

            var nodes = new Stack<DbExpression>();
            nodes.Push(root);

            while (nodes.Count > 0)
            {
                var current = nodes.Pop();
                if (current.ExpressionKind != kind)
                {
                    yield return current;
                }
                else
                {
                    foreach (var node in getChildNodes(current).Reverse())
                    {
                        nodes.Push(node);
                    }
                }
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:35,代码来源:DbExpressionExtensions.cs


示例4: CreateMockExpression

 private static Mock<DbExpression> CreateMockExpression(DbExpressionKind kind)
 {
     var mockRoot = new Mock<DbExpression>();
     mockRoot.Setup(m => m.ExpressionKind).Returns(kind);
     
     return mockRoot;
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:DbExpressionExtensionsTests.cs


示例5: DbUnaryExpression

        internal DbUnaryExpression(DbExpressionKind kind, TypeUsage resultType, DbExpression argument)
            : base(kind, resultType)
        {
            DebugCheck.NotNull(argument);

            _argument = argument;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:DbUnaryExpression.cs


示例6: DbBinaryExpression

        internal DbBinaryExpression(DbExpressionKind kind, TypeUsage type, DbExpression left, DbExpression right)
            : base(kind, type)
        {
            DebugCheck.NotNull(left);
            DebugCheck.NotNull(right);

            _left = left;
            _right = right;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:9,代码来源:DbBinaryExpression.cs


示例7: DbBinaryExpression

        internal DbBinaryExpression(DbExpressionKind kind, TypeUsage type, DbExpression left, DbExpression right)
            : base(kind, type)
        {
            Debug.Assert(left != null, "DbBinaryExpression.Left cannot be null");
            Debug.Assert(right != null, "DbBinaryExpression.Right cannot be null");

            _left = left;
            _right = right;
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:DbBinaryExpression.cs


示例8: CreateStringComparison

        private Expression CreateStringComparison(Expression left, Expression right, DbExpressionKind kind)
        {
            var method = Expression.Call(null, StringFunctions.CompareTo, left, right);
            var mode = GetCompareMode(kind);

            Expression res = Expression.Equal(method, Expression.Constant(mode.Item1));

            if (!mode.Item2)
            {
                res = Expression.Not(res);
            }

            return res;
        }
开发者ID:nozerowu,项目名称:ABP,代码行数:14,代码来源:TransformVisitor.Comparison.cs


示例9: FlattenAssociativeExpression

        /// <summary>
        /// Creates a flat list of the associative arguments.
        /// For example, for ((A1 + (A2 - A3)) + A4) it will create A1, (A2 - A3), A4
        /// Only 'unfolds' the given arguments that are of the given expression kind.        
        /// </summary>
        /// <param name="expressionKind"></param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        internal static IEnumerable<DbExpression> FlattenAssociativeExpression(
            DbExpressionKind expressionKind, params DbExpression[] arguments)
        {
            if (!_associativeExpressionKinds.Contains(expressionKind))
            {
                return arguments;
            }

            var outputArguments = new List<DbExpression>();
            foreach (var argument in arguments)
            {
                ExtractAssociativeArguments(expressionKind, outputArguments, argument);
            }
            return outputArguments;
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:23,代码来源:CommandTreeUtils.cs


示例10: ExtractAssociativeArguments

        /// <summary>
        /// Helper method for FlattenAssociativeExpression.
        /// Creates a flat list of the associative arguments and appends to the given argument list.
        /// For example, for ((A1 + (A2 - A3)) + A4) it will add A1, (A2 - A3), A4 to the list.
        /// Only 'unfolds' the given expression if it is of the given expression kind.
        /// </summary>
        /// <param name="expressionKind"></param>
        /// <param name="argumentList"></param>
        /// <param name="expression"></param>
        private static void ExtractAssociativeArguments(
            DbExpressionKind expressionKind, List<DbExpression> argumentList, DbExpression expression)
        {
            if (expression.ExpressionKind != expressionKind)
            {
                argumentList.Add(expression);
                return;
            }

            //All associative expressions are binary, thus we must be dealing with a DbBinaryExpresson or 
            // a DbArithmeticExpression with 2 arguments.
            var binaryExpression = expression as DbBinaryExpression;
            if (binaryExpression != null)
            {
                ExtractAssociativeArguments(expressionKind, argumentList, binaryExpression.Left);
                ExtractAssociativeArguments(expressionKind, argumentList, binaryExpression.Right);
                return;
            }

            var arithExpression = (DbArithmeticExpression)expression;
            ExtractAssociativeArguments(expressionKind, argumentList, arithExpression.Arguments[0]);
            ExtractAssociativeArguments(expressionKind, argumentList, arithExpression.Arguments[1]);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:32,代码来源:CommandTreeUtils.cs


示例11: MatchKind

 /// <summary>
 /// Constructs a new pattern that will match an expression with the specified <see cref="DbExpressionKind"/>.
 /// </summary>
 internal static Func<DbExpression, bool> MatchKind(DbExpressionKind kindToMatch)
 {
     return (e => e.ExpressionKind == kindToMatch);
 }
开发者ID:uQr,项目名称:referencesource,代码行数:7,代码来源:PatternMatchRules.cs


示例12: IsCompatible

 public bool IsCompatible(DbExpressionKind expressionKind)
 {
   switch (expressionKind)
   {
     case DbExpressionKind.Filter:
       return Where == null && Columns.Count == 0;
     case DbExpressionKind.Project:
       return Columns.Count == 0;
     case DbExpressionKind.Limit:
       return Limit == null;
     case DbExpressionKind.Skip:
       return Skip == null;
     case DbExpressionKind.Sort:
       return Columns.Count == 0 &&
           GroupBy == null &&
           OrderBy == null;
     case DbExpressionKind.GroupBy:
       return Columns.Count == 0 &&
           GroupBy == null &&
           OrderBy == null &&
           Limit == null;
   }
   throw new InvalidOperationException();
 }
开发者ID:eeeee,项目名称:mysql-connector-net,代码行数:24,代码来源:SelectStatement.cs


示例13: VisitExprKind

 private void VisitExprKind(DbExpressionKind kind)
 {
     _key.Append('[');
     _key.Append(_exprKindNames[(int)kind]);
     _key.Append(']');
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:6,代码来源:ExpressionKeyGen.cs


示例14: TransformIntersectOrExcept

        /// <summary>
        /// This method is used for translating <see cref="DbIntersectExpression"/> and <see cref="DbExceptExpression"/>,
        /// and for translating the "Except" part of <see cref="DbSkipExpression"/>.
        /// into the follwoing expression:
        /// 
        /// A INTERSECT B, A EXCEPT B
        /// 
        /// (DISTINCT)
        ///  |
        /// FILTER
        ///  |
        ///  | - Input: A
        ///  | - Predicate:(NOT)
        ///                 |
        ///                 ANY 
        ///                 |
        ///                 | - Input: B
        ///                 | - Predicate:  (B.b1 = A.a1 or (B.b1 is null and A.a1 is null))
        ///                             AND (B.b2 = A.a2 or (B.b2 is null and A.a2 is null))
        ///                             AND ... 
        ///                             AND (B.bn = A.an or (B.bn is null and A.an is null)))
        ///
        /// Here, A corresponds to right and B to left. 
        /// (NOT) is present when transforming Except
        /// for the purpose of translating <see cref="DbExceptExpression"/> or <see cref="DbSkipExpression"/>.   
        /// (DISTINCT) is present when transforming for the purpose of translating 
        /// <see cref="DbExceptExpression"/> or <see cref="DbIntersectExpression"/>.  
        /// 
        /// For <see cref="DbSkipExpression"/>, the input to ANY is caped with project which projects out only 
        /// the columns represented in the sortExpressionsOverLeft list and only these are used in the predicate.
        /// This is because we want to support skip over input with non-equal comarable columns and we have no way to recognize these.
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="expressionKind"></param>
        /// <param name="sortExpressionsOverLeft">note that this list gets destroyed by this method</param>
        /// <param name="sortExpressionsBindingVariableName"></param>
        /// <returns></returns>
        private DbExpression TransformIntersectOrExcept(
            DbExpression left, DbExpression right, DbExpressionKind expressionKind, IList<DbPropertyExpression> sortExpressionsOverLeft,
            string sortExpressionsBindingVariableName)
        {
            var negate = (expressionKind == DbExpressionKind.Except) || (expressionKind == DbExpressionKind.Skip);
            var distinct = (expressionKind == DbExpressionKind.Except) || (expressionKind == DbExpressionKind.Intersect);

            var leftInputBinding = left.Bind();
            var rightInputBinding = right.Bind();

            IList<DbPropertyExpression> leftFlattenedProperties = new List<DbPropertyExpression>();
            IList<DbPropertyExpression> rightFlattenedProperties = new List<DbPropertyExpression>();

            FlattenProperties(leftInputBinding.Variable, leftFlattenedProperties);
            FlattenProperties(rightInputBinding.Variable, rightFlattenedProperties);

            //For Skip, we need to ignore any columns that are not in the original sort list. We can recognize these by comparing the left flattened properties and
            // the properties in the list sortExpressionsOverLeft
            // If any such columns exist, we need to add an additional project, to keep the rest of the columns from being projected, as if any among these
            // are non equal comparable, SQL Server 2000 throws.
            if (expressionKind == DbExpressionKind.Skip)
            {
                if (RemoveNonSortProperties(
                    leftFlattenedProperties, rightFlattenedProperties, sortExpressionsOverLeft, leftInputBinding.VariableName,
                    sortExpressionsBindingVariableName))
                {
                    rightInputBinding = CapWithProject(rightInputBinding, rightFlattenedProperties);
                }
            }

            Debug.Assert(
                leftFlattenedProperties.Count == rightFlattenedProperties.Count,
                "The left and the right input to INTERSECT or EXCEPT have a different number of properties");
            Debug.Assert(leftFlattenedProperties.Count != 0, "The inputs to INTERSECT or EXCEPT have no properties");

            //Build the predicate for the quantifier:
            //   (B.b1 = A.a1 or (B.b1 is null and A.a1 is null))
            //      AND (B.b2 = A.a2 or (B.b2 is null and A.a2 is null))
            //      AND ... 
            //      AND (B.bn = A.an or (B.bn is null and A.an is null)))
            DbExpression existsPredicate = null;

            for (var i = 0; i < leftFlattenedProperties.Count; i++)
            {
                //A.ai == B.bi
                DbExpression equalsExpression = leftFlattenedProperties[i].Equal(rightFlattenedProperties[i]);

                //A.ai is null AND B.bi is null
                DbExpression leftIsNullExpression = leftFlattenedProperties[i].IsNull();
                DbExpression rightIsNullExpression = rightFlattenedProperties[i].IsNull();
                DbExpression bothNullExpression = leftIsNullExpression.And(rightIsNullExpression);

                DbExpression orExpression = equalsExpression.Or(bothNullExpression);

                if (i == 0)
                {
                    existsPredicate = orExpression;
                }
                else
                {
                    existsPredicate = existsPredicate.And(orExpression);
                }
//.........这里部分代码省略.........
开发者ID:jimmy00784,项目名称:entityframework,代码行数:101,代码来源:Sql8ExpressionRewriter.cs


示例15: CreateMockArgumentExpression

        private static Mock<DbPropertyExpression> CreateMockArgumentExpression(DbExpressionKind kind)
        {
            var mockLeftExpression = new Mock<DbPropertyExpression>();
            mockLeftExpression.Setup(m => m.ExpressionKind).Returns(kind);

            return mockLeftExpression;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:7,代码来源:SqlGeneratorTests.cs


示例16: CombinedProjectionExpression

 public CombinedProjectionExpression(DbExpressionKind setOperator, List<VisitedExpression> list)
 {
     _setOperator = setOperator == DbExpressionKind.UnionAll ? "UNION ALL" : setOperator == DbExpressionKind.Except ? "EXCEPT" : "INTERSECT";
     _list = list;
 }
开发者ID:Emill,项目名称:Npgsql,代码行数:5,代码来源:VisitedExpression.cs


示例17: CombinedProjectionExpression

 public CombinedProjectionExpression(VisitedExpression first, DbExpressionKind setOperator, VisitedExpression second)
 {
     _first = first;
     _setOperator = setOperator == DbExpressionKind.UnionAll ? "UNION ALL" : setOperator == DbExpressionKind.Except ? "EXCEPT" : "INTERSECT";
     _second = second;
 }
开发者ID:josephatngige,项目名称:Npgsql,代码行数:6,代码来源:VisitedExpression.cs


示例18: CreateMockDbArgumentExpression

        private static Mock<DbExpression> CreateMockDbArgumentExpression(
            PrimitiveTypeKind typeKind,
            DbExpressionKind expressionKind,
            bool? isUnicode)
        {
            var mockEdmType = new Mock<PrimitiveType>();
            mockEdmType.Setup(m => m.BuiltInTypeKind).Returns(BuiltInTypeKind.PrimitiveType);
            mockEdmType.Setup(m => m.PrimitiveTypeKind).Returns(typeKind);

            var mockTypeUsage = new Mock<TypeUsage>();
            mockTypeUsage.Setup(m => m.EdmType).Returns(mockEdmType.Object);

            if (isUnicode.HasValue)
            {
                var mockFacet = new Mock<Facet>();
                mockFacet.Setup(m => m.Value).Returns(isUnicode.Value);
                mockFacet.Setup(m => m.Identity).Returns(DbProviderManifest.UnicodeFacetName);

                mockTypeUsage.Setup(m => m.Facets).Returns(
                    new ReadOnlyMetadataCollection<Facet>(
                        new MetadataCollection<Facet>
                            {
                                mockFacet.Object
                            }));
            }
            else
            {
                mockTypeUsage.Setup(m => m.Facets).Returns(new ReadOnlyMetadataCollection<Facet>(new MetadataCollection<Facet>()));
            }

            var mockExpression = new Mock<DbExpression>();
            mockExpression.Setup(m => m.ResultType).Returns(mockTypeUsage.Object);
            mockExpression.Setup(m => m.ExpressionKind).Returns(expressionKind);

            return mockExpression;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:36,代码来源:SqlGeneratorTests.cs


示例19: CreateMockBinaryExpression

        private static Mock<DbBinaryExpression> CreateMockBinaryExpression(
            Mock<DbPropertyExpression> mockLeftExpression,
            Mock<DbPropertyExpression> mockRightExpression,
            DbExpressionKind kind)
        {
            SetupMockArguments(mockLeftExpression, mockRightExpression);

            var mockBinaryExpression = new Mock<DbBinaryExpression>();
            mockBinaryExpression.Setup(m => m.ExpressionKind).Returns(kind);
            mockBinaryExpression.Setup(m => m.Left).Returns(mockLeftExpression.Object);
            mockBinaryExpression.Setup(m => m.Right).Returns(mockRightExpression.Object);

            return mockBinaryExpression;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:14,代码来源:SqlGeneratorTests.cs


示例20: HandleJoinExpression

        private SqlFragment HandleJoinExpression(DbExpressionBinding left, DbExpressionBinding right, 
            DbExpressionKind joinType, DbExpression joinCondition)
        {
            JoinFragment join = new JoinFragment();
            join.JoinType = Metadata.GetOperator(joinType);

            join.Left = VisitInputExpression(left.Expression, left.VariableName, left.VariableType);
            WrapJoinInputIfNecessary(join.Left, false);
            join.Right = VisitInputExpression(right.Expression, right.VariableName, right.VariableType);
            WrapJoinInputIfNecessary(join.Right, true);

            // now handle the ON case
            if (joinCondition != null)
                join.Condition = joinCondition.Accept(this);
            return join;
        }
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:16,代码来源:SelectGenerator.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DbFilterExpression类代码示例发布时间:2022-05-24
下一篇:
C# DbExpression类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap