public static void updateproductrecord(int productid) { using (var context = new AdventureWorksEntities()) { var product = context.Products.Find(productid); product.Name = "Steve Bruce Buffer fasa"; context.SaveChanges(); } }
public static void removeproductrecord(int productid) { using (var context = new AdventureWorksEntities()) { var product = context.Products.Find(productid); context.Products.Remove(product); context.SaveChanges(); } }
public static void insertproductrecord() { using (var context = new AdventureWorksEntities()) { var product = new Product() { ProductID = context.Products.AsEnumerable <Product>().Last().ProductID + 1, Name = "New Product 16", ProductNumber = "156", Color = "Red", StandardCost = new decimal(1000.97), ListPrice = new decimal(2000), Size = "Large", ThumbNailPhoto = new byte[100], ThumbnailPhotoFileName = "FileName", ProductCategory = context.ProductCategories.First <ProductCategory>(), ProductModel = context.ProductModels.First() }; context.Products.Add(product); context.SaveChanges(); context.Database.Log = x => System.Diagnostics.Debug.WriteLine(x); } }