protected override Expression VisitParameter(ParameterExpression expression) { var name = expression.Name; if (expression.Type.Name == "TraversalData`2") { var prefix = LinqUtility.MemberNameFromMap(name, "graph", ModelVisitor); ModelVisitor.QueryText.AppendFormat(" {{ {0} : {1}, {2} : {3}, {4} : {5} }} ", LinqUtility.ResolvePropertyName("vertex"), LinqUtility.ResolvePropertyName($"{prefix}_Vertex"), LinqUtility.ResolvePropertyName("edge"), LinqUtility.ResolvePropertyName($"{prefix}_Edge"), LinqUtility.ResolvePropertyName("path"), LinqUtility.ResolvePropertyName($"{prefix}_Path")); return(expression); } if (expression.Type.Name == "ShortestPathData`2") { var prefix = LinqUtility.MemberNameFromMap(name, "graph", ModelVisitor); ModelVisitor.QueryText.AppendFormat(" {{ {0} : {1}, {2} : {3} }} ", LinqUtility.ResolvePropertyName("vertex"), LinqUtility.ResolvePropertyName($"{prefix}_Vertex"), LinqUtility.ResolvePropertyName("edge"), LinqUtility.ResolvePropertyName($"{prefix}_Edge")); return(expression); } ModelVisitor.QueryText.AppendFormat(" {0} ", LinqUtility.ResolvePropertyName(name)); return(expression); }
protected override Expression VisitMember(MemberExpression expression) { var member = expression.Expression as MemberExpression; if (member != null && member.Expression.Type.Name == "IGrouping`2") { ModelVisitor.QueryText.AppendFormat(" {0} ", LinqUtility.ResolvePropertyName(expression.Member.Name)); } // Select(g=>g.Key) else if (expression.Expression.Type.Name == "IGrouping`2") { var groupByClause = LinqUtility.PriorGroupBy(ModelVisitor)[0]; var newExpression = groupByClause.Selector as NewExpression; if (newExpression != null) { ModelVisitor.QueryText.Append(" { "); for (var i = 0; i < newExpression.Members.Count; i++) { var memberName = newExpression.Members[i].Name; ModelVisitor.QueryText.AppendFormat(" {0} : {1} ", LinqUtility.ResolvePropertyName(memberName), LinqUtility.ResolvePropertyName(memberName)); if (i != newExpression.Members.Count - 1) { ModelVisitor.QueryText.Append(" , "); } } ModelVisitor.QueryText.Append(" } "); } if (groupByClause.Selector.NodeType != ExpressionType.New) { ModelVisitor.QueryText.AppendFormat(" {0} ", LinqUtility.ResolvePropertyName(groupByClause.CollectVariableName)); } } else if (expression.Expression.Type.Name == "TraversalData`2" || expression.Expression.Type.Name == "ShortestPathData`2") { var parameterExpression = expression.Expression as ParameterExpression; if (parameterExpression == null) { throw new InvalidOperationException( "[TraversalData`2|ShortestPathData`2] VisitMember, expected a ParameterExpression"); } var prefix = LinqUtility.MemberNameFromMap(parameterExpression.Name, "graph", ModelVisitor); ModelVisitor.QueryText.AppendFormat( LinqUtility.ResolvePropertyName($"{prefix}_{expression.Member.Name}")); } else { Visit(expression.Expression); ModelVisitor.QueryText.AppendFormat(".{0} ", LinqUtility.ResolveMemberName(ModelVisitor.Db, expression.Member)); } return(expression); }