Esempio n. 1
0
        private static void PrintCustomerOrders(string custID)
        {
            int id = int.Parse(custID);

            using (AutoLotEntities context = new AutoLotEntities())
            {
                var carsOnOrder = from o in context.Orders
                                  where o.CustID == id
                                  select o.Inventory;
                Console.WriteLine("\nCustomer has {0} orders pending:", carsOnOrder.Count());

                foreach (var item in carsOnOrder)
                {
                    Console.WriteLine("-> {0} {1} named {2}.",
                                      item.Color, item.Make, item.PetName);
                }
            }
        }
Esempio n. 2
0
        private static void CallStoredProc()
        {
            using (AutoLotEntities context = new AutoLotEntities())
            {
                // Approach #1.
                ObjectParameter input  = new ObjectParameter("carID", 83);
                ObjectParameter output = new ObjectParameter("petName", typeof(string));

                // Call ExecuteFunction off the context....
                //var objectContext = (context as IObjectContextAdapter).ObjectContext;
                ((IObjectContextAdapter)context).ObjectContext.ExecuteFunction("GetPetName", input, output);

                // Approach #2.
                // ....or use the strongly typed method on the context.
                context.GetPetName(83, output);

                Console.WriteLine("Car #83 is named {0}", output.Value);
            }
        }