public static void AddRIAppDemoService(this IServiceCollection services,
                                               Action <RIAppDemoServiceEFOptions> configure)
        {
            services.AddEFDomainService <RIAppDemoServiceEF, AdventureWorksLT2012Context>((options) =>
            {
                options.ClientTypes = () => new[] { typeof(TestModel), typeof(KeyVal), typeof(StrKeyVal), typeof(RadioVal), typeof(HistoryItem), typeof(TestEnum2) };

                ValidatorConfig.RegisterValidators(options.ValidatorRegister);
                DataManagerConfig.RegisterDataManagers(options.DataManagerRegister);

                RIAppDemoServiceEFOptions svcOptions = new RIAppDemoServiceEFOptions();
                configure?.Invoke(svcOptions);

                options.UserFactory = svcOptions.GetUser;

                string connString = svcOptions.ConnectionString ?? throw new ArgumentNullException(nameof(svcOptions.ConnectionString));

                services.AddDbContext <AdventureWorksLT2012Context>((dbOptions) =>
                {
                    dbOptions.UseSqlServer(connString, (sqlOptions) =>
                    {
                        // sqlOptions.UseRowNumberForPaging();
                    }).AddInterceptors(new CommandInterceptor());
                }, ServiceLifetime.Transient);
            });

            services.AddScoped <IWarmUp>((sp => sp.GetRequiredService <RIAppDemoServiceEF>()));
        }
예제 #2
0
        public static void AddRIAppDemoService(this IServiceCollection services,
                                               Action <SvcOptions> configure)
        {
            services.AddEF2DomainService <RIAppDemoServiceEF, ADWDbContext>((options) =>
            {
                ValidatorConfig.RegisterValidators(options.ValidatorRegister);
                DataManagerConfig.RegisterDataManagers(options.DataManagerRegister);

                options.ClientTypes = () => new[] { typeof(TestModel), typeof(KeyVal), typeof(StrKeyVal), typeof(RadioVal), typeof(HistoryItem), typeof(TestEnum2) };

                SvcOptions svcOptions = new SvcOptions();
                configure?.Invoke(svcOptions);

                options.UserFactory = svcOptions.GetUser;
            });

            services.AddScoped <ADWDbContext>((sp) =>
            {
                ADWDbContext res = new ADWDbContext(sp.GetRequiredService <DBConnectionFactory>().GetRIAppDemoConnection());
                return(res);
            });
        }