本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}