示例#1
0
 public void Insert(Product product)
 {
     const string query = "INSERT INTO Products (ProductName,ProductDescription,Quantity,IsOnSale) VALUES(@ProductName,@ProductDescription,@Quantity,@IsOnSale)";
     using (var conn = new SqlConnection(connString))
     {
         conn.Query(query, product);
     }
 }
示例#2
0
文件: AdoDb.cs 项目: inemtsev/ormtest
 public void Insert(Product product)
 {
     string query = string.Format("INSERT INTO Products (ProductName,ProductDescription,Quantity,IsOnSale) VALUES('{0}','{1}','{2}','{3}')", product.ProductName, product.ProductDescription, product.Quantity, product.IsOnSale);
     using (var connection = new SqlConnection(connString))
     {
         using (var command = new SqlCommand(query, connection))
         {
             connection.Open();
             command.ExecuteNonQuery();
         }
     }
 }
示例#3
0
文件: EfDb.cs 项目: inemtsev/ormtest
 public void Insert(Product product)
 {
     _productsDb.Products.Add(product);
 }