public void Add(Product entity)
 {
     using (var db = new BatikStoreEntities())
     {
         db.Products.AddObject(entity);
         db.SaveChanges();
     }
 }
Exemple #2
0
        static void work2()
        {
            Console.WriteLine("Start thread:{0}", Thread.CurrentThread.ManagedThreadId);
            //UnitOfWork uow = new UnitOfWork();
            //UnitOfWork.Begin("DBServer");
            //IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();
            //IProductRepository prodRep = new ProductRepository("DBServer");
            //Console.WriteLine("ProductID : {0} ", prodRep.Single(x => string.IsNullOrEmpty( x.CUSTSN)).ProductID);
            //using (UnitOfWork uow = new UnitOfWork())
            //{
             IRepository<Product> prodRep = new Repository<Product>("HPIMES");
                //foreach (Product item in prodRep.Find(x => x.Model == "PCBE15YA837Y"))
                //{
                //    if (string.IsNullOrEmpty(item.CUSTSN))
                //    {
                //        item.CUSTSN = "";
                //    }
                //    Thread.Sleep(20);
                //    Console.WriteLine("thread:{0} ProductID:{1} CustomSN:{2}", Thread.CurrentThread.ManagedThreadId, item.ProductID, item.CUSTSN);
                //}

                Product p1 = new Product
                {
                    ProductID = "A35500006 ",
                    CUSTSN = "test1111",
                    Model = "PCBE15YA837Y",
                    PCBID = "",
                    Udt = DateTime.Now.AddDays(-1)
                };
                //prodRep.Delete(p);
                prodRep.Update(p1);
                
                //prodRep.Save();
                UnitOfWork.ThreadCommit();
                Console.WriteLine("Update!!");
            //}
            Console.WriteLine("End thread:{0}", Thread.CurrentThread.ManagedThreadId);
        }
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="number">Initial value of the Number property.</param>
 /// <param name="price">Initial value of the Price property.</param>
 /// <param name="promoted">Initial value of the Promoted property.</param>
 /// <param name="dateEntered">Initial value of the DateEntered property.</param>
 public static Product CreateProduct(global::System.Int32 id, global::System.String name, global::System.String number, global::System.Decimal price, global::System.Boolean promoted, global::System.DateTime dateEntered)
 {
     Product product = new Product();
     product.Id = id;
     product.Name = name;
     product.Number = number;
     product.Price = price;
     product.Promoted = promoted;
     product.DateEntered = dateEntered;
     return product;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProducts(Product product)
 {
     base.AddObject("Products", product);
 }
 public void Update(Product entity)
 {
     using (var db = new BatikStoreEntities())
     {
         var existing = db.Products.SingleOrDefault(c => c.Id == entity.Id);
         if (existing != null)
         {
             db.Products.ApplyCurrentValues(entity);
             db.SaveChanges();
         }
     }
 }
Exemple #6
0
 partial void DeleteProduct(Product instance);
Exemple #7
0
 partial void UpdateProduct(Product instance);
Exemple #8
0
 partial void InsertProduct(Product instance);