예제 #1
0
 public static void Configure(DbContextOptionsBuilder <SalesDbContext> builder, string connectionString)
 {
     builder.UseSqlServer(connectionString, builder =>
     {
         builder.CommandTimeout(60 * 1000);
         //builder.EnableRetryOnFailure(5, TimeSpan.FromSeconds(5), null);
     });
 }
            public void Setting_CommandTimeout_to_negative_value_throws()
            {
                var optionsBuilder = new DbContextOptionsBuilder().UseSqlServer("No=LoveyDovey");

                Assert.Throws <InvalidOperationException>(() => optionsBuilder.CommandTimeout(-55));

                using (var context = new TimeoutContext())
                {
                    Assert.Null(context.Database.GetCommandTimeout());

                    Assert.Throws <ArgumentException>(
                        () => context.Database.SetCommandTimeout(-3));

                    Assert.Throws <ArgumentException>(
                        () => context.Database.SetCommandTimeout(-99));
                }
            }
            public void Setting_CommandTimeout_to_negative_value_throws()
            {
                var optionsBuilder = new DbContextOptionsBuilder().UseSqlServer("No=LoveyDovey");

                Assert.Throws<InvalidOperationException>(() => optionsBuilder.CommandTimeout(-55));

                using (var context = new TimeoutContext())
                {
                    Assert.Null(context.Database.GetCommandTimeout());

                    Assert.Throws<ArgumentException>(
                        () => context.Database.SetCommandTimeout(-3));

                    Assert.Throws<ArgumentException>(
                        () => context.Database.SetCommandTimeout(-99));
                }
            }