public static void Exec(Action <TestDataContext> action) { lock (LOCK) { if (INSTANCE == null) { var helper = new SqlServerTestDbHelper("L2S"); helper.ResetDatabase(); INSTANCE = new TestDataContext(helper.ConnectionString); INSTANCE.ExecuteCommand( $@"create table {nameof(RemoteGroupingStress_DataItem)} ( {nameof(RemoteGroupingStress_DataItem.ID)} int identity primary key, {nameof(RemoteGroupingStress_DataItem.Num)} int not null, {nameof(RemoteGroupingStress_DataItem.NullNum)} int, {nameof(RemoteGroupingStress_DataItem.Date)} datetime2 not null, {nameof(RemoteGroupingStress_DataItem.NullDate)} datetime2 )" ); INSTANCE.ExecuteCommand( $@"create table {nameof(Summary_DataItem)} ( {nameof(Summary_DataItem.ID)} int identity primary key, {nameof(Summary_DataItem.Group1)} nvarchar, {nameof(Summary_DataItem.Group2)} nvarchar, {nameof(Summary_DataItem.Value)} int )" ); } action(INSTANCE); } }
public static async Task ExecAsync(Func <UnitOfWork, Task> action) { XpoDefault.Session = null; if (DATA_LAYER == null) { var sqlHelper = new SqlServerTestDbHelper("Xpo"); sqlHelper.ResetDatabase(); var dict = new ReflectionDictionary(); dict.GetDataStoreSchema( typeof(DefaultSort.DataItem), typeof(RemoteGroupingStress.DataItem), typeof(Summary.DataItem), typeof(Bug339.DataItem), typeof(PaginateViaPrimaryKey.DataItem), typeof(Async.DataItem) ); var provider = XpoDefault.GetConnectionProvider( sqlHelper.ConnectionString, AutoCreateOption.SchemaOnly ); DATA_LAYER = new SimpleDataLayer(dict, provider); } using (var uow = new UnitOfWork(DATA_LAYER)) { await action(uow); } }
public static void Exec(Action <UnitOfWork> action) { lock (LOCK) { XpoDefault.Session = null; if (DATA_LAYER == null) { var sqlHelper = new SqlServerTestDbHelper("Xpo"); sqlHelper.ResetDatabase(); var dict = new ReflectionDictionary(); dict.GetDataStoreSchema( typeof(DefaultSort.DataItem), typeof(RemoteGroupingStress.DataItem), typeof(Summary.DataItem) ); var provider = XpoDefault.GetConnectionProvider( sqlHelper.ConnectionString, AutoCreateOption.SchemaOnly ); DATA_LAYER = new SimpleDataLayer(dict, provider); } using (var uow = new UnitOfWork(DATA_LAYER)) { action(uow); } } }
public static async Task ExecAsync(Func <TestDbContext, Task> action) { if (INSTANCE == null) { var helper = new SqlServerTestDbHelper("EF6"); helper.ResetDatabase(); INSTANCE = new TestDbContext(helper.ConnectionString); INSTANCE.Database.CreateIfNotExists(); } await action(INSTANCE); }
public static void Exec(Action <TestDbContext> action) { lock (LOCK) { if (INSTANCE == null) { var helper = new SqlServerTestDbHelper("DevExtreme_AspNet_Data_Tests_EF6_DB"); helper.ResetDatabase(); INSTANCE = new TestDbContext(helper.ConnectionString); INSTANCE.Database.CreateIfNotExists(); } action(INSTANCE); } }
public static void Exec(Action <TestDbContext> action) { if (INSTANCE == null) { var helper = new SqlServerTestDbHelper("EFCore1"); helper.ResetDatabase(); var options = new DbContextOptionsBuilder() .UseSqlServer(helper.ConnectionString) .Options; INSTANCE = new TestDbContext(options); INSTANCE.Database.EnsureCreated(); } action(INSTANCE); }
public static async Task ExecAsync(Func <ISession, Task> action) { if (FACTORY == null) { var sqlHelper = new SqlServerTestDbHelper("NH"); sqlHelper.ResetDatabase(); FACTORY = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2012.ConnectionString(sqlHelper.ConnectionString)) .Mappings(m => m.FluentMappings.AddFromAssembly(typeof(SessionFactoryHelper).Assembly)) .ExposeConfiguration(config => new SchemaExport(config).Create(false, true)) .BuildSessionFactory(); } using (var session = FACTORY.OpenSession()) { await action(session); } }
public static async Task ExecAsync(Func <TestDbContext, Task> action) { if (INSTANCE == null) { var helper = new SqlServerTestDbHelper("EFCore2"); helper.ResetDatabase(); var options = new DbContextOptionsBuilder() .UseSqlServer(helper.ConnectionString) .ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)) .Options; INSTANCE = new TestDbContext(options); INSTANCE.Database.EnsureCreated(); } await action(INSTANCE); }
public static async Task ExecAsync(Func <TestDbContext, Task> action) { if (INSTANCE == null) { var efVersion = typeof(DbContext).Assembly.GetName().Version.Major; var helper = new SqlServerTestDbHelper("EFCore" + efVersion); helper.ResetDatabase(); var options = new DbContextOptionsBuilder() .UseSqlServer(helper.ConnectionString) #if EFCORE2 .ConfigureWarnings(warnings => warnings.Throw(Microsoft.EntityFrameworkCore.Diagnostics.RelationalEventId.QueryClientEvaluationWarning)) #endif .Options; INSTANCE = new TestDbContext(options); INSTANCE.Database.EnsureCreated(); } await action(INSTANCE); }