예제 #1
0
 public void InitDataBase(string connectionString)
 {
     DB.Current.Execute(Const.DBCreateScript);
     Dictionary<int, int> provinces = new Dictionary<int, int>();
     var table = new Province("ORMTest");
     foreach (var province in ORMPerformanceTest.TestData.ProvinceData.GetProvinces())
     {
         var dbProvince = table.Insert(new { Code = province.Code, Name = province.Name });
         provinces.Add(province.Code, (int)dbProvince.ID);
     }
     BulkUploadToSql bulk =
            BulkUploadToSql.Load(
               ORMPerformanceTest.TestData.HomeData.GetHomes()
                    .Select(
                        i =>
                            new ORMPerformanceTest.Tests.Bulk.Home
                            {
                                AddTime = DateTime.Now,
                                BuildYear = i.BuildYear,
                                City = i.City,
                                Description = i.Description,
                                Price = i.Price,
                                Surface = i.Surface,
                                ProvinceId = provinces[i.HomeProvince.Code],
                            }), "Home", 10000, connectionString);
     bulk.Flush();
 }
예제 #2
0
        private static int InsertTest(string connectionString)
        {
            var table = new Home("ORMTest");
            var provinces = new Province("ORMTest").All();

            foreach (var home in ORMPerformanceTest.TestData.HomeData.Get100Homes())
            {
                table.Insert(new
                {
                    BuildYear = home.BuildYear,
                    City = home.City,
                    Description = home.Description,
                    ProvinceId = provinces.First(i => i.Code == home.HomeProvince.Code).Id,
                    Price = home.Price,
                    Surface = home.Surface,
                    AddTime = DateTime.Now
                });
            }
            return 100;
        }