예제 #1
0
        public StoreProduct GetProductByID(long productID)
        {
            StoreProduct result = null;

            using (CostarDataContext dc = _conn.GetContext())
            {
                result = dc.StoreProducts.Where(p => p.ProductID == productID).FirstOrDefault();
            }
            return(result);
        }
예제 #2
0
        /// <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();
            //}
        }