Inheritance: System.Data.Objects.DataClasses.EntityObject
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="productID">Initial value of the ProductID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="productNumber">Initial value of the ProductNumber property.</param>
 /// <param name="makeFlag">Initial value of the MakeFlag property.</param>
 /// <param name="finishedGoodsFlag">Initial value of the FinishedGoodsFlag property.</param>
 /// <param name="safetyStockLevel">Initial value of the SafetyStockLevel property.</param>
 /// <param name="reorderPoint">Initial value of the ReorderPoint property.</param>
 /// <param name="standardCost">Initial value of the StandardCost property.</param>
 /// <param name="listPrice">Initial value of the ListPrice property.</param>
 /// <param name="daysToManufacture">Initial value of the DaysToManufacture property.</param>
 /// <param name="sellStartDate">Initial value of the SellStartDate property.</param>
 /// <param name="rowguid">Initial value of the rowguid property.</param>
 /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
 public static Product CreateProduct(global::System.Int32 productID, global::System.String name, global::System.String productNumber, global::System.Boolean makeFlag, global::System.Boolean finishedGoodsFlag, global::System.Int16 safetyStockLevel, global::System.Int16 reorderPoint, global::System.Decimal standardCost, global::System.Decimal listPrice, global::System.Int32 daysToManufacture, global::System.DateTime sellStartDate, global::System.Guid rowguid, global::System.DateTime modifiedDate)
 {
     Product product = new Product();
     product.ProductID = productID;
     product.Name = name;
     product.ProductNumber = productNumber;
     product.MakeFlag = makeFlag;
     product.FinishedGoodsFlag = finishedGoodsFlag;
     product.SafetyStockLevel = safetyStockLevel;
     product.ReorderPoint = reorderPoint;
     product.StandardCost = standardCost;
     product.ListPrice = listPrice;
     product.DaysToManufacture = daysToManufacture;
     product.SellStartDate = sellStartDate;
     product.rowguid = rowguid;
     product.ModifiedDate = modifiedDate;
     return product;
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string br = Environment.NewLine;

            // We will write classes for 'Supplier' and 'Product'
            // This is a typical one-to-many association
            // One Supplier object has a collection of zero or more Product objects
            // See the classes below

            // Create a Supplier object
            Supplier microsoft = new Supplier()
            {
                Id = 1,
                Name = "Microsoft Corporation",
                Country = "USA"
            };

            // Create a Product object
            var keyboard = new Product()
            {
                Id = 2,
                Name = "Keyboard",
                MSRP = 45,
                ProductCode = "qwe123",
                UPC = "0987654321"
            };

            // Add the Product object to the Supplier's collection of Product objects
            microsoft.Products.Add(keyboard);
            // For in-memory only objects, we must also set the other end
            keyboard.Supplier = microsoft;

            // Add a new Product object directly to the Supplier's collection
            // Notice that we set the supplier property for this in-memory only object
            microsoft.Products.Add(new Product()
            {
                Id = 1,
                MSRP = 25,
                Name = "Mouse",
                ProductCode = "abc123",
                UPC = "1234567890",
                Supplier = microsoft
            });

            // Show the results
            Console.WriteLine(string.Format("Supplier '{0}' sells these {1} products:",
                microsoft.Name, microsoft.Products.Count));
            foreach (var product in microsoft.Products)
            {
                Console.WriteLine(string.Format("{0} (UPC {1}), MSRP is {2}",
                    product.Name, product.UPC, product.MSRP.ToString("C")));
            }

            Console.WriteLine(br);

            // For the 'keyboard' product, walk through the navigation property
            // and get access to properties in the related object
            Console.WriteLine(string.Format("The {0} product is supplied by {1} ({2})",
                keyboard.Name, keyboard.Supplier.Name, keyboard.Supplier.Country));

            Console.WriteLine(br);
        }
 /// <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);
 }