Esempio n. 1
0
 private static void CallStoredProc() // Вызов хранимой процедуры
 {
     using (var entities = new AutoLotEntities())
     {
         // ObjectParameter inputParameter = new ObjectParameter("CarId", 83);
         var outputParameter = new ObjectParameter("petName", typeof(string));
         /*int petName = */ entities.GetPetName(83, outputParameter);
         Console.WriteLine("Car #83 is named {0}", outputParameter.Value);
     }
 }
Esempio n. 2
0
        private static void CallStoredProc()
        {
            using (AutoLotEntities context = new AutoLotEntities())
            {
                ObjectParameter input  = new ObjectParameter("carID", 83);
                ObjectParameter output = new ObjectParameter("petName", typeof(string));

                // Call ExecuteFunction off the context....
                context.ExecuteFunction("GetPetName", input, output);

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

                Console.WriteLine("Car #83 is named {0}", output.Value);
            }
        }
Esempio n. 3
0
        private static void CallStoredProc()
        {
            using (AutoLotEntities context = new AutoLotEntities())
            {
                //  方法 #1
                ObjectParameter input  = new ObjectParameter("carID", 83);
                ObjectParameter output = new ObjectParameter("petName", typeof(string));

                //  调用上下文的ExecuteFunction方法
                //context.ExecuteFunction("GetPetName", input, output);

                //  方法 #2
                //  或使用上下文中强类型的方法
                context.GetPetName(83, output);

                Console.WriteLine("Car #83 is named {0}", output.Value);
            }
        }
Esempio n. 4
0
        private static void CallStoredProc()
        {
            using (AutoLotEntities context = new AutoLotEntities())
            {
                //方法一
                ObjectParameter input  = new ObjectParameter("carID", 83);
                ObjectParameter output = new ObjectParameter("petName", typeof(string));

                //调用储存过程
                ObjectContext objectContext = ((IObjectContextAdapter)context).ObjectContext;
                objectContext.ExecuteFunction("GetPetName", input, output);

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

                //方法二
                context.GetPetName(83, output);
                Console.WriteLine("Car #83 is named {0}.", output.Value);
            }
        }