Пример #1
0
        internal LiteReferenceExpression WithExpandLite(ExpandLite expandLite)
        {
            switch (expandLite)
            {
            case ExpandLite.EntityEager:
                return(new LiteReferenceExpression(this.Type, this.Reference, this.CustomToStr, lazyToStr: false, eagerEntity: true));

            case ExpandLite.ToStringEager:
                return(new LiteReferenceExpression(this.Type, this.Reference, this.CustomToStr, lazyToStr: false, eagerEntity: false));

            case ExpandLite.ToStringLazy:
                return(new LiteReferenceExpression(this.Type, this.Reference, this.CustomToStr, lazyToStr: true, eagerEntity: false));

            case ExpandLite.ToStringNull:
                return(new LiteReferenceExpression(this.Type, this.Reference, Expression.Constant(null, typeof(string)), lazyToStr: true, eagerEntity: false));

            default:
                throw new NotImplementedException();
            }
        }
Пример #2
0
        public static IQueryable <T> ExpandLite <T, L>(this IQueryable <T> source, Expression <Func <T, Lite <L> > > liteSelector, ExpandLite expandLite)
            where L : class, IEntity
        {
            if (source == null)
            {
                throw new ArgumentNullException("query");
            }

            return(source.Provider.CreateQuery <T>(Expression.Call(null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new Type[] { typeof(T), typeof(L) }), new Expression[] { source.Expression, Expression.Quote(liteSelector), Expression.Constant(expandLite) })));
        }