コード例 #1
0
 public DataSet GetAllDataSet()
 {
     using (MimariContext mimariContext = new MimariContext())
     {
         string sorgu = "Select * from Product";
         return(mimariContext.ExecDataReaderProc(sorgu));
     }
 }
コード例 #2
0
 public void Add(Product product)
 {
     using (MimariContext mimariContext = new MimariContext())
     {
         string sorgu = "Insert Into Product (ProductName,UnitPrice,QuantityPerUnit) Values (@ProductName,@UnitPrice,@QuantityPerUnit)";
         Dictionary <string, object> dictList = new Dictionary <string, object>();
         dictList.Add("@ProductName", product.ProductName);
         dictList.Add("@UnitPrice", product.UnitPrice);
         dictList.Add("@QuantityPerUnit", product.UnitsInStock);
         mimariContext.ExecNonQueryProc(sorgu, dictList);
     }
 }
コード例 #3
0
 public void Update(Product product)
 {
     using (MimariContext mimariContext = new MimariContext())
     {
         string sorgu = "Update Product SET ProductName=@ProductName,UnitPrice=@UnitPrice,QuantityPerUnit=@QuantityPerUnit WHERE id=@id";
         Dictionary <string, object> dictList = new Dictionary <string, object>();
         dictList.Add("@ProductName", product.ProductName);
         dictList.Add("@UnitPrice", product.UnitPrice);
         dictList.Add("@QuantityPerUnit", product.UnitsInStock);
         dictList.Add("@id", product.ProductId);
         mimariContext.ExecNonQueryProc(sorgu, dictList);
     }
 }
コード例 #4
0
        public List <Product> GetAllList()
        {
            List <Product> _products = new List <Product>();

            using (MimariContext mimariContext = new MimariContext())
            {
                string sorgu = "Select * from Product";
                var    ds    = mimariContext.ExecDataReaderProc(sorgu);
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    _products.Add(new Product {
                        ProductId       = Convert.ToInt32(item["id"]),
                        ProductName     = Convert.ToString(item["ProductName"]),
                        UnitPrice       = Convert.ToInt32(item["UnitPrice"]),
                        UnitsInStock    = Convert.ToInt32(item["UnitInStock"]),
                        QuantityPerUnit = Convert.ToString(item["QuantityPerUnit"])
                    });
                }
                return(_products);
            }
        }
コード例 #5
0
 public Product GetId(int id)
 {
     using (MimariContext mimariContext = new MimariContext())
     {
         Product product = null;
         string  sorgu   = "Select * From Product Where id=@id";
         Dictionary <string, object> dictList = new Dictionary <string, object>();
         dictList.Add("@id", id);
         var ds = mimariContext.ExecDataReaderProc(sorgu, dictList);
         foreach (DataRow item in ds.Tables[0].Rows)
         {
             product = new Product {
                 ProductId       = Convert.ToInt32(item["id"]),
                 ProductName     = Convert.ToString(item["ProductName"]),
                 UnitPrice       = Convert.ToInt32(item["UnitPrice"]),
                 UnitsInStock    = Convert.ToInt32(item["UnitInStock"]),
                 QuantityPerUnit = Convert.ToString(item["QuantityPerUnit"])
             };
         }
         return(product);
     }
 }