示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var context = new EFRecipesEntities())
            {
                context.ExecuteStoreCommand("delete from chapter4.[order]");
                context.ExecuteStoreCommand("delete from chapter4.webcustomer");

                var cust1 = new WebCustomer {
                    Name = "Joan Steward"
                };
                var cust2 = new WebCustomer {
                    Name = "Allen Colbert"
                };
                var cust3 = new WebCustomer {
                    Name = "Phil Marlowe"
                };
                var order1 = new Order {
                    Amount = 29.95M, OrderDate = DateTime.Parse("3/18/2010")
                };
                var order2 = new Order {
                    Amount = 84.99M, OrderDate = DateTime.Parse("3/20/2010")
                };
                var order3 = new Order {
                    Amount = 99.95M, OrderDate = DateTime.Parse("4/10/2010")
                };
                order1.WebCustomer = cust1;
                order2.WebCustomer = cust2;
                order3.WebCustomer = cust3;
                context.Orders.AddObject(order1);
                context.Orders.AddObject(order2);
                context.Orders.AddObject(order3);
                context.SaveChanges();
            }
        }
        /// <summary>
        /// Create a new WebCustomer object.
        /// </summary>
        /// <param name="customerId">Initial value of the CustomerId property.</param>
        /// <param name="name">Initial value of the Name property.</param>
        public static WebCustomer CreateWebCustomer(global::System.Int32 customerId, global::System.String name)
        {
            WebCustomer webCustomer = new WebCustomer();

            webCustomer.CustomerId = customerId;
            webCustomer.Name       = name;
            return(webCustomer);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the WebCustomers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToWebCustomers(WebCustomer webCustomer)
 {
     base.AddObject("WebCustomers", webCustomer);
 }