public UnitTest1(ITestOutputHelper output) { _output = output; var services = new ServiceCollection(); services.AddDbContext <MyDbContext>(opt => opt.UseMySql("server=10.0.0.146;Database=demo;Uid=root;Pwd=123456;Port=3306;AllowLoadLocalInfile=true")) .AddBatchDB <MyDbContext>(); _bulk = services.BuildServiceProvider().GetService <ISqlBulk>(); }
public SqlBulk(DbContext context, IServiceProvider provider) { if (context.Database.IsMySql()) { _bulk = provider.GetService <IMysqlBulk>(); } else if (context.Database.IsSqlServer()) { _bulk = provider.GetService <ISqlServerBulk>(); } }