public StoreProduct GetProductByID(long productID) { StoreProduct result = null; using (CostarDataContext dc = _conn.GetContext()) { result = dc.StoreProducts.Where(p => p.ProductID == productID).FirstOrDefault(); } return(result); }
/// <summary> /// Add or Edit StoreProductInventory /// </summary> /// <param name="product"></param> public void SaveProductInventory(StoreProductInventory proInv) { using (CostarDataContext dc = _conn.GetContext()) { if (proInv.InventoryID > 0) { dc.StoreProductInventories.Attach(proInv, true); } if (proInv.InventoryID == 0) { dc.StoreProductInventories.InsertOnSubmit(proInv); } dc.SubmitChanges(); } //using (CostarDataContext linq = new CostarDataContext()) //{ // if (proInv.InventoryID > 0) // { // StoreProductInventory inv = linq.StoreProductInventories.Where(c => c.InventoryID == proInv.InventoryID).SingleOrDefault(); // Common.CommonClass.CopyObjectProperty(proInv, inv); // } // else // { // linq.StoreProductInventories.InsertOnSubmit(proInv); // } // linq.SubmitChanges(); //} }