internal WBooleanExpression GetWherePredicate(GremlinToSqlContext currentContext, GremlinVariable firstVar, Predicate predicate, TraversalRing traversalRing) { AndPredicate andPredicate = predicate as AndPredicate; if (andPredicate != null) { List <WBooleanExpression> booleanList = new List <WBooleanExpression>(); foreach (var p in andPredicate.PredicateList) { booleanList.Add(GetWherePredicate(currentContext, firstVar, p, traversalRing)); } return(SqlUtil.ConcatBooleanExprWithAnd(booleanList)); } OrPredicate orPredicate = predicate as OrPredicate; if (orPredicate != null) { List <WBooleanExpression> booleanList = new List <WBooleanExpression>(); foreach (var p in orPredicate.PredicateList) { booleanList.Add(GetWherePredicate(currentContext, firstVar, p, traversalRing)); } return(SqlUtil.ConcatBooleanExprWithOr(booleanList)); } var selectKeys = new List <string>() { predicate.Value as string }; var selectTraversal = new List <GraphTraversal2>() { traversalRing.Next() }; var selectVar = GetSelectVar(currentContext, GremlinKeyword.Pop.Last, selectKeys, selectTraversal); var firstExpr = firstVar.GetDefaultProjection().ToScalarExpression(); var secondExpr = selectVar.GetDefaultProjection().ToScalarExpression(); return(SqlUtil.GetBooleanComparisonExpr(firstExpr, secondExpr, predicate)); }