예제 #1
0
 public void 新增多筆()
 {
     using (var db = LabEmployee2DB.CreateSecretDb())
     {
         var employee1 = new Employee {
             Id = Guid.NewGuid(), Name = "余小章", Age = 20
         };
         var employee2 = new Employee {
             Id = Guid.NewGuid(), Name = "小章", Age = 18
         };
         var employees = new List <Employee> {
             employee2, employee1
         };
         var count = db.Insert(employees, "Employee");
         Assert.IsTrue(count == 2);
     }
 }
예제 #2
0
        public void 新增一筆()
        {
            //using (var db = LabEmployee2DB.CreateSecretDb())
            //{
            //    if (db.Connection.State == ConnectionState.Closed)
            //    {
            //        db.Connection.Open();
            //    }

            //    var count = db.Insert(new Employee {Id = Guid.NewGuid(), Name = "小章", Age = 18});
            //    Assert.IsTrue(count == 1);

            //    db.Connection.Close();
            //}

            using (var db = LabEmployee2DB.CreateSecretDb())
            {
                var count = db.Insert(new Employee {
                    Id = Guid.NewGuid(), Name = "小章", Age = 18
                });
                Assert.IsTrue(count == 1);
            }
        }