static void Main(string[] args) { //Create a method that places a new order in the Northwind database. // The order should contain several order items. // Use transaction to ensure the data consistency. Product p1 = new Product(); p1.ProductName = "Tesla"; p1.UnitPrice = 20.20M; DAO.db.Products.AddObject(p1); Product p2 = new Product(); p2.ProductName = "Kashon"; p2.UnitPrice = 14.20M; DAO.db.Products.AddObject(p2); List<Product> products = new List<Product>(); products.Add(p1); products.Add(p2); Order order = new Order(); order.ShipCountry = "Bulgaria"; order.CustomerID = "ALFKI"; DAO.db.Orders.AddObject(order); DAO.db.SaveChanges(); DAO.AddOrderDetails(products, order); }
/// <summary> /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProducts(Product product) { base.AddObject("Products", product); }
/// <summary> /// Create a new Product object. /// </summary> /// <param name="productID">Initial value of the ProductID property.</param> /// <param name="productName">Initial value of the ProductName property.</param> /// <param name="discontinued">Initial value of the Discontinued property.</param> public static Product CreateProduct(global::System.Int32 productID, global::System.String productName, global::System.Boolean discontinued) { Product product = new Product(); product.ProductID = productID; product.ProductName = productName; product.Discontinued = discontinued; return product; }