static IChildProjection BuildChild(ChildProjectionExpression childProj) { var proj = childProj.Projection; Type type = proj.UniqueFunction == null?proj.Type.ElementType() !: proj.Type; if (!type.IsInstantiationOf(typeof(KeyValuePair <,>))) { throw new InvalidOperationException("All child projections should create KeyValuePairs"); } Scope scope = new Scope( alias: proj.Select.Alias, positions: proj.Select.Columns.Select((c, i) => new { c.Name, i }).ToDictionary(p => p.Name !, p => p.i) /*CSBUG*/ ); var types = type.GetGenericArguments(); var command = QueryFormatter.Format(proj.Select); if (childProj.IsLazyMList) { types[1] = types[1].GetGenericArguments()[0]; return(giLazyChild.GetInvoker(types)(proj.Projector, scope, childProj.Token, command)); } else { return(giEagerChild.GetInvoker(types)(proj.Projector, scope, childProj.Token, command)); } }
protected internal virtual Expression VisitChildProjection(ChildProjectionExpression child) { ProjectionExpression proj = (ProjectionExpression)this.Visit(child.Projection); Expression key = this.Visit(child.OuterKey); if (proj != child.Projection || key != child.OuterKey) { return(new ChildProjectionExpression(proj, key, child.IsLazyMList, child.Type, child.Token)); } return(child); }
protected internal override Expression VisitChildProjection(ChildProjectionExpression child) { Expression key = this.Visit(child.OuterKey); ProjectionExpression proj = (ProjectionExpression)UnusedColumnRemover.Remove(child.Projection); if (proj != child.Projection || key != child.OuterKey) { return(new ChildProjectionExpression(proj, key, child.IsLazyMList, child.Type, child.Token)); } return(child); }
protected Expression VisitMListChildProjection(ChildProjectionExpression child, MemberExpression field) { Expression outer = Visit(child.OuterKey); if (outer != child.OuterKey) { child = new ChildProjectionExpression(child.Projection, outer, child.IsLazyMList, child.Type, child.Token); } return(scope.LookupMList(row, child, field)); }
protected internal override Expression VisitChildProjection(ChildProjectionExpression child) { Expression outer = Visit(child.OuterKey); if (outer != child.OuterKey) { child = new ChildProjectionExpression(child.Projection, outer, child.IsLazyMList, child.Type, child.Token); } return(scope.LookupEager(row, child)); }
protected internal override Expression VisitChildProjection(ChildProjectionExpression child) { var result = base.VisitChildProjection(child); if (!child.IsLazyMList) { list.Add(child); } return(result); }
public Expression LookupEager(Expression row, ChildProjectionExpression cProj) { if (cProj.IsLazyMList) { throw new InvalidOperationException("IsLazyMList not expected at this stage"); } Type type = cProj.Projection.UniqueFunction == null?cProj.Type.ElementType() : cProj.Type; MethodInfo mi = miLookup.MakeGenericMethod(cProj.OuterKey.Type, type); Expression call = Expression.Call(row, mi, Expression.Constant(cProj.Token), cProj.OuterKey); if (cProj.Projection.UniqueFunction != null) { throw new InvalidOperationException("Eager ChildProyection with UniqueFunction '{0}' not expected at this stage".FormatWith(cProj.Projection.UniqueFunction)); } return(call); }
public Expression LookupMList(Expression row, ChildProjectionExpression cProj, MemberExpression field) { if (!cProj.IsLazyMList) { throw new InvalidOperationException("Not IsLazyMList not expected at this stage"); } if (!cProj.Type.IsMList()) { throw new InvalidOperationException("Lazy ChildProyection of type '{0}' instead of MList".FormatWith(cProj.Type.TypeName())); } if (cProj.Projection.UniqueFunction != null) { throw new InvalidOperationException("Lazy ChildProyection with UniqueFunction '{0}'".FormatWith(cProj.Projection.UniqueFunction)); } MethodInfo mi = miLookupRequest.MakeGenericMethod(cProj.OuterKey.Type, cProj.Type.ElementType()); return(Expression.Call(row, mi, Expression.Constant(cProj.Token), cProj.OuterKey, field)); }
protected internal override Expression VisitChildProjection(ChildProjectionExpression child) { return(child); }
protected internal override Expression VisitChildProjection(ChildProjectionExpression child) { throw InvalidSqlExpression(child); }
private bool CompareChildProjection(ChildProjectionExpression a, ChildProjectionExpression b) { return(Compare(a.Projection, b.Projection) && Compare(a.OuterKey, b.OuterKey) && a.IsLazyMList == b.IsLazyMList); }