Esempio n. 1
0
        //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 MySQLServiceDBConfiguration SetOption(this MySQLServiceDBConfiguration value, Func <DbContextOptionsBuilder, DbContextOptionsBuilder> function)
        {
            DbContextOptionsBuilder builder = new DbContextOptionsBuilder <MySQLService>();

            builder       = function(builder);
            value.Options = builder.Options;
            return(value);
        }
Esempio n. 2
0
        public static MySQLServiceDBConfiguration SetConnectionString(string ConnectionString)
        {
            var value = new MySQLServiceDBConfiguration();

            value.ConnectionString = ConnectionString;

            ServicesContainer.AddSingleton <MySQLServiceDBConfiguration>(value);

            ServicesContainer.AddTransient <MySQLService>();

            return(value);
        }
Esempio n. 3
0
        public MySQLService() : base(ServicesContainer.GetService <MySQLServiceDBConfiguration>().Options)
        {
            Options = ServicesContainer.GetService <MySQLServiceDBConfiguration>();

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

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

            foreach (var item in result)
            {
                DbSetCollection.Add(item, method.MakeGenericMethod(item).Invoke(this, null));
            }
        }
Esempio n. 4
0
 public static MySQLServiceDBConfiguration SetAssembly(this MySQLServiceDBConfiguration value, Assembly assembly)
 {
     value.Assembly = assembly;
     return(value);
 }
Esempio n. 5
0
 public static MySQLServiceDBConfiguration SetOption(this MySQLServiceDBConfiguration value, DbContextOptions option)
 {
     value.Options = option;
     return(value);
 }