コード例 #1
0
        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));
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
            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));
            }
コード例 #5
0
            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));
            }
コード例 #6
0
            protected internal override Expression VisitChildProjection(ChildProjectionExpression child)
            {
                var result = base.VisitChildProjection(child);

                if (!child.IsLazyMList)
                {
                    list.Add(child);
                }

                return(result);
            }
コード例 #7
0
        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);
        }
コード例 #8
0
        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));
        }
コード例 #9
0
 protected internal override Expression VisitChildProjection(ChildProjectionExpression child)
 {
     return(child);
 }
コード例 #10
0
 protected internal override Expression VisitChildProjection(ChildProjectionExpression child)
 {
     throw InvalidSqlExpression(child);
 }
コード例 #11
0
 private bool CompareChildProjection(ChildProjectionExpression a, ChildProjectionExpression b)
 {
     return(Compare(a.Projection, b.Projection) &&
            Compare(a.OuterKey, b.OuterKey) &&
            a.IsLazyMList == b.IsLazyMList);
 }