示例#1
0
        internal virtual void Where(GremlinToSqlContext currentContext, string startKey, Predicate predicate, TraversalRing traversalRing)
        {
            var selectKey = new List <string> {
                startKey
            };
            var selectTraversal = new List <GraphTraversal2> {
                traversalRing.Next()
            };
            var firstVar = GetSelectVar(currentContext, GremlinKeyword.Pop.Last, selectKey, selectTraversal);

            currentContext.AddPredicate(GetWherePredicate(currentContext, firstVar, predicate, traversalRing));
        }
示例#2
0
        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));
        }
示例#3
0
 internal virtual void Where(GremlinToSqlContext currentContext, Predicate predicate, TraversalRing traversalRing)
 {
     currentContext.AddPredicate(GetWherePredicate(currentContext, this, predicate, traversalRing));
 }