//public static ServiceDBConfigurationEntityFramework SetOption<TContext>( this ServiceDBConfigurationEntityFramework value,  Action<DbContextOptionsBuilder> optionsAction = null, ServiceLifetime contextLifetime = ServiceLifetime.Scoped) where TContext : DbContext;

        //public static ServiceDBConfigurationEntityFramework SetOption<TContext>( this ServiceDBConfigurationEntityFramework value, ServiceLifetime contextLifetime) where TContext : DbContext;

        //public static ServiceDBConfigurationEntityFramework SetOption<TContext>( this ServiceDBConfigurationEntityFramework value,  Action<IServiceProvider, DbContextOptionsBuilder> optionsAction, ServiceLifetime contextLifetime = ServiceLifetime.Scoped) where TContext : DbContext;

        public static SQLServerServiceDBConfiguration SetOption(this SQLServerServiceDBConfiguration value, Func <DbContextOptionsBuilder, DbContextOptionsBuilder> function)
        {
            DbContextOptionsBuilder builder = new DbContextOptionsBuilder <SQLServerService>();

            builder       = function(builder);
            value.Options = builder.Options;
            return(value);
        }
        public static SQLServerServiceDBConfiguration SetConnectionString(string ConnectionString)
        {
            var value = new SQLServerServiceDBConfiguration();

            value.ConnectionString = ConnectionString;

            ServicesContainer.AddSingleton <SQLServerServiceDBConfiguration>(value);

            ServicesContainer.AddTransient <SQLServerService>();

            return(value);
        }
Пример #3
0
        public SQLServerService() : base(ServicesContainer.GetService <SQLServerServiceDBConfiguration>().Options)
        {
            Options = ServicesContainer.GetService <SQLServerServiceDBConfiguration>();

            var method = this.GetType().GetMethod("Set");

            var result = Options.Assembly.GetTypes().Where(x => x.GetInterface("IEntitySQLServer", true) != null);

            foreach (var item in result)
            {
                var db = method.MakeGenericMethod(item).Invoke(this, null);
                DbSetCollection.Add(item, db);
            }
        }
 public static SQLServerServiceDBConfiguration SetAssembly(this SQLServerServiceDBConfiguration value, Assembly assembly)
 {
     value.Assembly = assembly;
     return(value);
 }
 public static SQLServerServiceDBConfiguration SetOption(this SQLServerServiceDBConfiguration value, DbContextOptions option)
 {
     value.Options = option;
     return(value);
 }