Ejemplo n.º 1
0
        public static IQueryConfiguration <TEntity> Configure(Func <IQueryConfigurator <TEntity>, IQueryConfigurator <TEntity> > configureCallback)
        {
            if (configureCallback == null)
            {
                throw new ArgumentNullException(nameof(configureCallback));
            }

            var inputConfigurator = new QueryConfigurator <TEntity>();

            var outputConfigurator = configureCallback(inputConfigurator);

            return(outputConfigurator.OutputConfiguration);
        }
Ejemplo n.º 2
0
        public static IQueryConfiguration <TEntity, TOut> Configure <TOut>(Func <IQueryConfigurator <TEntity>, IQueryConfigurator <TEntity, TOut> > configureCallback)
            where TOut : class
        {
            if (configureCallback == null)
            {
                throw new ArgumentNullException(nameof(configureCallback));
            }

            var inputConfigurator = new QueryConfigurator <TEntity>();

            var transformConfigurator = configureCallback(inputConfigurator);

            return(transformConfigurator.TransformConfiguration);
        }
        public static IQueryProvider <TContext> Build <TContext>(TContext context, Action <IQueryConfigurator <TContext> > options)
            where TContext : DbContext
        {
            // Create a new configuration.
            var configuration = new QueryConfiguration <TContext>();

            // Configure the configuration.
            var configurator = new QueryConfigurator <TContext>(context, configuration);

            options(configurator);

            // Create the query provider with the configuration.
            return(new QueryProvider <TContext>(configuration));
        }
        public static IQueryConfigurator <TIn, TOut> Select <TIn, TOut>(this IQueryConfigurator <TIn> configurator, Expression <Func <TIn, TOut> > selector)
            where TIn : class
            where TOut : class
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }
            if (selector == null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            var transformSpecification = new SelectQuerySpecification <TIn, TOut>(selector);
            var nextConfigurator       = new QueryConfigurator <TIn, TOut>(configurator, transformSpecification);

            return(nextConfigurator);
        }