public ConstantProvider(QueryContext context, MemberExpression expr) { var constant = (ConstantExpression)expr.Expression; Value = constant.Type.GetField(expr.Member.Name).GetValue(constant.Value); ParamName = context.NextParam(this); }
public WhereConverter(Select select, QueryContext context) { if (select == null) throw new ArgumentNullException("select"); if (context == null) throw new ArgumentNullException("context"); _select = select; _context = context; }
public QueryConverter(QueryContext context) { _context = context; }
public bool VisitPath(QueryContext context, PropertyInfo[] path, out BracketedName alias, out PropertyMap map) { var entity = EntityMap; alias = Alias; map = null; for (var i = 0; i < path.Length - 1; i++) { var prop = path[i]; var item = JoinGroup.FindJoin(prop); if (item == null) { var reference = entity.FindReferenceMap(prop); if (reference == null) return false; item = JoinGroup.AddJoin(alias, context.NextAlias(), reference); } alias = item.ToAlias; entity = item.ReferenceMap.To; } var last = path[path.Length - 1]; map = entity.FindPropertyMap(last) ?? entity.FindReferenceMap(last); return true; }
public Select(QueryContext context) : this(context.GetEntityMap(context.EntityType), context.NextAlias()) { }
public ParameterProvider(QueryContext context, ParameterExpression expr) { ExpressionName = expr.Name; ParamName = context.NextParam(this); }
public ConstantProvider(QueryContext context, object value) { Value = value; ParamName = context.NextParam(this); }
public ConstantProvider(QueryContext context, ConstantExpression expr) { Value = expr.Value; ParamName = context.NextParam(this); }
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; }