Пример #1
0
        public static ILoadWithQueryable <TEntity, TProperty> ThenLoad <TEntity, TPreviousProperty, TProperty>(
            this ILoadWithQueryable <TEntity, IEnumerable <TPreviousProperty> > source,
            [InstantHandle] Expression <Func <TPreviousProperty, TProperty> > selector)
            where TEntity : class
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (selector == null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            var result = source.Provider.CreateQuery <TEntity>(
                Expression.Call(null,
                                MethodHelper.GetMethodInfo(ThenLoad, source, selector),
                                new[] { source.Expression, Expression.Quote(selector) }));

            return(new LoadWithQueryable <TEntity, TProperty>(result));
        }
Пример #2
0
        [Pure]         // Methods.LinqToDB.ThenLoadFromManyManyFilter
        public static ILoadWithQueryable <TEntity, TProperty> ThenLoad <TEntity, TPreviousProperty, TProperty>(
            this ILoadWithQueryable <TEntity, IEnumerable <TPreviousProperty> > source,
            [InstantHandle] Expression <Func <TPreviousProperty, IEnumerable <TProperty> > > selector,
            [InstantHandle] Expression <Func <IQueryable <TProperty>, IQueryable <TProperty> > > loadFunc)
            where TEntity : class
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (selector == null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            var currentSource = ProcessSourceQueryable?.Invoke(source) ?? source;

            var result = currentSource.Provider.CreateQuery <TEntity>(
                Expression.Call(null,
                                MethodHelper.GetMethodInfo(ThenLoad, source, selector, loadFunc),
                                currentSource.Expression, Expression.Quote(selector), Expression.Quote(loadFunc)));

            return(new LoadWithQueryable <TEntity, TProperty>(result));
        }