public Product CreateProduct(Product product)
 {
     var dc = new DataClassesDataContext(_connectionString);
     if (product.Category != null)
     {
         dc.Categories.Attach(product.Category, false);
     }
     if (product.Supplier != null)
     {
         dc.Suppliers.Attach(product.Supplier, false);
     }
     dc.Products.InsertOnSubmit(product);
     dc.SubmitChanges();
     return product;
 }
 partial void DeleteProduct(Product instance);
 partial void UpdateProduct(Product instance);
 partial void InsertProduct(Product instance);
		private void detach_Products(Product entity)
		{
			this.SendPropertyChanging();
			entity.Category = null;
		}
		private void attach_Products(Product entity)
		{
			this.SendPropertyChanging();
			entity.Category = this;
		}
		private void detach_Products(Product entity)
		{
			this.SendPropertyChanging();
			entity.Supplier = null;
		}
		private void attach_Products(Product entity)
		{
			this.SendPropertyChanging();
			entity.Supplier = this;
		}
 public Product UpdateProduct(Product product)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Products.Attach(product, ReadProduct(product.ProductID));
     dc.SubmitChanges();
     return product;
 }
 public void DeleteProduct(Product product)
 {
     var dc = new DataClassesDataContext(_connectionString);
     IQueryable<Product> s = from e in dc.Products
                             where e.ProductID == product.ProductID
                             select e;
     dc.Products.DeleteOnSubmit(s.First());
     dc.SubmitChanges();
 }