Beispiel #1
0
 public static ProcDataReader GetDataReader(Type proc, Type type)
 {
     lock (mReaders)
     {
         Hashtable rh = (Hashtable)mReaders[proc];
         if (rh == null)
         {
             rh = new Hashtable();
             mReaders.Add(proc, rh);
         }
         ProcDataReader reader = (ProcDataReader)rh[type];
         if (reader == null)
         {
             reader = new ProcDataReader(type);
             rh.Add(type, reader);
         }
         return(reader);
     }
 }
Beispiel #2
0
        public IList ListProc(Type entity, object parameter)
        {
            TimeWatch.Start("Peanut->Execute Proce Return List");
            System.Type itemstype = System.Type.GetType("System.Collections.Generic.List`1");
            itemstype = itemstype.MakeGenericType(entity);
            IList result = (IList)Activator.CreateInstance(itemstype);

            Mappings.ProcDataReader dr = Mappings.ProcDataReader.GetDataReader(parameter.GetType(), entity);
            using (IDataReader reader = mHandler.ExecProcReader(parameter))
            {
                while (reader.Read())
                {
                    object item = Activator.CreateInstance(entity);
                    dr.ReaderToObject(reader, item);
                    result.Add(item);
                }
            }
            TimeWatch.End();
            return(result);
        }