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


C# MethodCallExpression.GetRightMostMember方法代码示例

本文整理汇总了C#中System.Linq.Expressions.MethodCallExpression.GetRightMostMember方法的典型用法代码示例。如果您正苦于以下问题:C# MethodCallExpression.GetRightMostMember方法的具体用法?C# MethodCallExpression.GetRightMostMember怎么用?C# MethodCallExpression.GetRightMostMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Linq.Expressions.MethodCallExpression的用法示例。


在下文中一共展示了MethodCallExpression.GetRightMostMember方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitStringQxMethodCall

		protected virtual Expression VisitStringQxMethodCall(MethodCallExpression e)
		{
			var member = e.GetRightMostMember();
            var methodName = e.Method.Name;

            switch (methodName)
            {
                case "StartsWith":
                case "EndsWith":
                case "QxLike":
                case "QxStartsWith":
                case "QxEndsWith":
                case "QxContains":
                    var useSuffix = methodName != "QxLike" && (methodName == "QxStartsWith" || methodName == "QxContains");
                    var usePrefix = methodName != "QxLike" && (methodName == "QxEndsWith" || methodName == "QxContains");
					var argValue = e.Arguments[1].Evaluate().ToStringOrNull();
                    var newValue = string.Format("{0}{1}{2}", usePrefix ? "%" : "", argValue, useSuffix ? "%" : "");
                    var constant = Expression.Constant(newValue);

					if(methodName == "QxStartsWith")
						_nodes.AddNode(CreateNewMemberNode(member).ToStartsWithNode());
					else if(methodName == "QxEndsWith")
						_nodes.AddNode(CreateNewMemberNode(member).ToEndsWithNode());
					else
						Visit(member);

                    _nodes.AddNode(new OperatorNode(Operator.Like()));
                    Visit(constant);
                    break;
                case "QxToLower":
					_nodes.AddNode(CreateNewMemberNode(member).ToLowerNode());
                    break;
                case "QxToUpper":
					_nodes.AddNode(CreateNewMemberNode(member).ToUpperNode());
                    break;
            }

            return e;
        }
开发者ID:BlackMael,项目名称:SisoDb-Provider,代码行数:39,代码来源:WhereParser.cs

示例2: VisitStringMethodCall

		protected virtual Expression VisitStringMethodCall(MethodCallExpression e)
		{
			var member = e.GetRightMostMember();
            var methodName = e.Method.Name;
            
            switch (methodName)
            {
                case "StartsWith":
					var startsWithValue = e.Arguments[0].Evaluate().ToStringOrNull();
					//Visit(member);
					_nodes.AddNode(CreateNewMemberNode(member).ToStartsWithNode());
                    _nodes.AddNode(new OperatorNode(Operator.Like()));
                    Visit(Expression.Constant(string.Concat(startsWithValue, "%")));
					break;
                case "EndsWith":
					var endsWithValue = e.Arguments[0].Evaluate().ToStringOrNull();
					//Visit(member);
					_nodes.AddNode(CreateNewMemberNode(member).ToEndsWithNode());
                    _nodes.AddNode(new OperatorNode(Operator.Like()));
                    Visit(Expression.Constant(string.Concat("%", endsWithValue)));
                    break;
                case "ToLower":
                    _nodes.AddNode(CreateNewMemberNode(member).ToLowerNode());
                    break;
                case "ToUpper":
                    _nodes.AddNode(CreateNewMemberNode(member).ToUpperNode());
                    break;
            }

            return e;
        }
开发者ID:BlackMael,项目名称:SisoDb-Provider,代码行数:31,代码来源:WhereParser.cs

示例3: VisitStringQxMethodCall

        protected virtual Expression VisitStringQxMethodCall(MethodCallExpression e)
        {
            var member = e.GetRightMostMember();

            var expressionIsNotForMember = member == null || member.Expression.NodeType == ExpressionType.Constant;
            if (expressionIsNotForMember)
                return Visit(Expression.Constant(e.Evaluate()));

            var methodName = e.Method.Name;

            switch (methodName)
            {
                case "QxContains":
                    Nodes.AddNode(CreateNewMemberNode(member).ToStringContainsNode(e.Arguments[1].Evaluate().ToStringOrNull()));
                    break;
                case "QxStartsWith":
                    Nodes.AddNode(CreateNewMemberNode(member).ToStringStartsWithNode(e.Arguments[1].Evaluate().ToStringOrNull()));
                    break;
                case "QxEndsWith":
                    Nodes.AddNode(CreateNewMemberNode(member).ToStringEndsWithNode(e.Arguments[1].Evaluate().ToStringOrNull()));
                    break;
                case "QxIsExactly":
                    Nodes.AddNode(CreateNewMemberNode(member).ToStringExactNode(e.Arguments[1].Evaluate().ToStringOrNull()));
                    break;
                case "QxLike":
                    Nodes.AddNode(CreateNewMemberNode(member).ToLikeNode(e.Arguments[1].Evaluate().ToStringOrNull()));
                    break;
                case "QxToLower":
                    Nodes.AddNode(CreateNewMemberNode(member).ToLowerNode());
                    break;
                case "QxToUpper":
                    Nodes.AddNode(CreateNewMemberNode(member).ToUpperNode());
                    break;
                default:
                    throw new SisoDbNotSupportedException("String query extension (Qx) method '{0}', is not supported.".Inject(methodName));
            }

            return e;
        }
开发者ID:MikaelEliasson,项目名称:SisoDb-Provider,代码行数:39,代码来源:WhereParser.cs

示例4: VisitSingleValueTypeQxMethodCall

        protected virtual Expression VisitSingleValueTypeQxMethodCall(MethodCallExpression e)
        {
            var member = e.GetRightMostMember();
            var methodName = e.Method.Name;

            switch (methodName)
            {
                case "QxIn":
                    Nodes.AddNode(CreateNewMemberNode(member).ToInSetNode(e.Arguments[1].Evaluate() as IEnumerable));
                    break;
                default:
                    throw new SisoDbNotSupportedException("Single value type query extension (Qx) method '{0}', is not supported.".Inject(methodName));
            }

            return e;
        }
开发者ID:MikaelEliasson,项目名称:SisoDb-Provider,代码行数:16,代码来源:WhereParser.cs

示例5: VisitStringMethodCall

        protected virtual Expression VisitStringMethodCall(MethodCallExpression e)
        {
            var member = e.GetRightMostMember();

            var expressionIsNotForMember = member == null || member.Expression.NodeType == ExpressionType.Constant;
            if (expressionIsNotForMember)
                return Visit(Expression.Constant(e.Evaluate()));

            var methodName = e.Method.Name;
            switch (methodName)
            {
                case "Contains":
                    Nodes.AddNode(CreateNewMemberNode(member).ToStringContainsNode(e.Arguments[0].Evaluate().ToStringOrNull()));
                    break;
                case "StartsWith":
                    Nodes.AddNode(CreateNewMemberNode(member).ToStringStartsWithNode(e.Arguments[0].Evaluate().ToStringOrNull()));
                    break;
                case "EndsWith":
                    Nodes.AddNode(CreateNewMemberNode(member).ToStringEndsWithNode(e.Arguments[0].Evaluate().ToStringOrNull()));
                    break;
                case "ToLower":
                    Nodes.AddNode(CreateNewMemberNode(member).ToLowerNode());
                    break;
                case "ToUpper":
                    Nodes.AddNode(CreateNewMemberNode(member).ToUpperNode());
                    break;
            }

            return e;
        }
开发者ID:MikaelEliasson,项目名称:SisoDb-Provider,代码行数:30,代码来源:WhereParser.cs


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