コード例 #1
0
        static void Main(string[] args)
        {
            using (var context = new EFRecipesEntities())
            {
                context.ExecuteStoreCommand("delete from chapter6.weborder");
            }

            using (var context = new EFRecipesEntities())
            {
                var order = new WebOrder {
                    CustomerName = "Jim Allen", OrderDate = DateTime.Parse("5/3/2009"), IsDeleted = false, Amount = 200
                };
                context.WebOrders.AddObject(order);
                order = new WebOrder {
                    CustomerName = "John Stevens", OrderDate = DateTime.Parse("1/1/2006"), IsDeleted = false, Amount = 400
                };
                context.WebOrders.AddObject(order);
                order = new WebOrder {
                    CustomerName = "Russel Smith", OrderDate = DateTime.Parse("1/3/2006"), IsDeleted = true, Amount = 500
                };
                context.WebOrders.AddObject(order);
                order = new WebOrder {
                    CustomerName = "Mike Hammer", OrderDate = DateTime.Parse("3/6/2006"), IsDeleted = true, Amount = 1800
                };
                context.WebOrders.AddObject(order);
                order = new WebOrder {
                    CustomerName = "Steve Jones", OrderDate = DateTime.Parse("1/1/2003"), IsDeleted = true, Amount = 600
                };
                context.WebOrders.AddObject(order);
                context.SaveChanges();
            }

            using (var context = new EFRecipesEntities())
            {
                Console.WriteLine("Orders");
                Console.WriteLine("======");
                foreach (var order in context.WebOrders)
                {
                    Console.WriteLine("\nCustomer: {0}", order.CustomerName);
                    Console.WriteLine("OrderDate: {0}", order.OrderDate.ToShortDateString());
                    Console.WriteLine("Is Deleted: {0}", order.IsDeleted.ToString());
                    Console.WriteLine("Amount: {0}", order.Amount.ToString("C"));
                }
            }

            Console.WriteLine("Press <enter> to continue...");
            Console.ReadLine();
        }
コード例 #2
0
        /// <summary>
        /// Create a new WebOrder object.
        /// </summary>
        /// <param name="orderId">Initial value of the OrderId property.</param>
        /// <param name="customerName">Initial value of the CustomerName property.</param>
        /// <param name="orderDate">Initial value of the OrderDate property.</param>
        /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
        /// <param name="amount">Initial value of the Amount property.</param>
        public static WebOrder CreateWebOrder(global::System.Int32 orderId, global::System.String customerName, global::System.DateTime orderDate, global::System.Boolean isDeleted, global::System.Decimal amount)
        {
            WebOrder webOrder = new WebOrder();

            webOrder.OrderId = orderId;

            webOrder.CustomerName = customerName;

            webOrder.OrderDate = orderDate;

            webOrder.IsDeleted = isDeleted;

            webOrder.Amount = amount;

            return(webOrder);
        }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the WebOrders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToWebOrders(WebOrder webOrder)
 {
     base.AddObject("WebOrders", webOrder);
 }