private object GetShardingValue(WhereSegment whereSegment, ParameterContext parameterContext, String shardingColumn)
 {
     foreach (var andPredicate in whereSegment.GetAndPredicates())
     {
         return(GetShardingValue(andPredicate, parameterContext, shardingColumn));
     }
     return(null);
 }
        private ICollection <SimpleTableSegment> GetAllTablesFromWhere(WhereSegment where)
        {
            ICollection <SimpleTableSegment> result = new LinkedList <SimpleTableSegment>();

            foreach (var andPredicate in where.GetAndPredicates())
            {
                foreach (var predicate in andPredicate.GetPredicates())
                {
                    result.AddAll(new PredicateExtractor(GetSqlCommand().Tables, predicate).ExtractTables());
                }
            }
            return(result);
        }
Example #3
0
        protected override IQuerySegment MapLambdaExpression(LambdaExpression expression)
        {
            if (m_whereSegment != null)
            {
                return(base.MapLambdaExpression(expression));
            }

            var condition = Map(expression.Body);

            m_whereSegment = new WhereSegment(condition);

            return(m_whereSegment);
        }
        public override IASTNode VisitWhereClause(SqlServerCommandParser.WhereClauseContext context)
        {
            WhereSegment result  = new WhereSegment(context.Start.StartIndex, context.Stop.StopIndex);
            var          segment = Visit(context.expr());

            if (segment is OrPredicateSegment orPredicateSegment)
            {
                result.GetAndPredicates().AddAll(orPredicateSegment.GetAndPredicates());
            }
            else if (segment is PredicateSegment predicateSegment)
            {
                var andPredicate = new AndPredicateSegment();
                andPredicate.GetPredicates().Add(predicateSegment);
                result.GetAndPredicates().Add(andPredicate);
            }
            return(result);
        }
Example #5
0
        public override IASTNode VisitWhereClause(MySqlCommandParser.WhereClauseContext ctx)
        {
            WhereSegment result  = new WhereSegment(ctx.Start.StartIndex, ctx.Stop.StopIndex);
            IASTNode     segment = Visit(ctx.expr());

            if (segment is OrPredicateSegment orPredicateSegment)
            {
                result.GetAndPredicates().AddAll(((OrPredicateSegment)segment).GetAndPredicates());
            }
            else if (segment is PredicateSegment)
            {
                AndPredicateSegment andPredicate = new AndPredicateSegment();
                andPredicate.GetPredicates().Add((PredicateSegment)segment);
                result.GetAndPredicates().Add(andPredicate);
            }
            return(result);
        }