Esempio n. 1
0
 private static void CreateTable()
 {
     using (var conn = new SqlConnection(TestDbConnection.LocalDb.Northwind))
     {
         conn.Open();
         string sqlCommand = Northwind_Tables.Customers_Create();
         conn.Execute(sqlCommand);
     }
 }
Esempio n. 2
0
        private static void PrepareData()
        {
            List <Customer_Data> sourceData = new List <Customer_Data>();

            using (var sr = new StreamReader(@"Customer_Data.csv"))
            {
                using (var reader = new CsvReader(sr))
                {
                    var records = reader.GetRecords <Customer_Data>();
                    sourceData.AddRange(records);
                }
            }

            using (var conn = new SqlConnection(TestDbConnection.LocalDb.Northwind))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    var sqlCommand = Northwind_Tables.Customers_Insert();
                    conn.Execute(sqlCommand, sourceData, transaction: trans);
                    trans.Commit();
                }
            }
        }