Exemplo n.º 1
0
        private ISqlNode VisitWhere(ISqlNode parent, MethodCallExpression expr)
        {
            var select = (Select)parent;
            var whereConverter = new WhereConverter(select, _context);
            var whereExpr = whereConverter.Visit(ExpressionHelper.GetLambda(expr.Arguments[1]));

            select.Where = whereExpr;

            return select;
        }
Exemplo n.º 2
0
        static string GetWhere(Expression<Func<Student, bool>> expr)
        {
            var convention = new DefaultConvention();
            var builder = new EntityMapBuilder<Student>(convention);

            var map = ((EntityMapBuilder<Student>)builder
                        .Key(_ => _.ID, "Student_id"))
                        .Build();

            var context = new QueryContext(new[]{map}, "");
            var selectEntity = new Select(map, "t0");
            var whereParser = new WhereConverter(selectEntity, context);

            var node = whereParser.Visit(expr);
            node.Render(context.Writer);
            var result = context.Writer.GetResult();

            return result;
        }