コード例 #1
0
 public object ToSingle(RequestContext context, IDataReaderWrapper dataReader, Type targetType, bool isDispose = true)
 {
     try
     {
         dataReader.Read();
         var rowParser = dataReader.GetRowParser(targetType);
         return(rowParser(dataReader));
     }
     finally
     {
         Dispose(dataReader, isDispose);
     }
 }
コード例 #2
0
        public async Task <object> ToSingleAsync(RequestContext context, IDataReaderWrapper dataReader, Type targetType, bool isDispose = true)
        {
            try
            {
                await dataReader.ReadAsync();

                var rowParser = dataReader.GetRowParser(targetType);
                return(rowParser(dataReader));
            }
            finally
            {
                Dispose(dataReader, isDispose);
            }
        }
コード例 #3
0
 public async Task <T> ToSingleAsync <T>(RequestContext context, IDataReaderWrapper dataReader, bool isDispose = true)
 {
     try
     {
         if (await dataReader.ReadAsync())
         {
             var targetType = typeof(T);
             var rowParser  = dataReader.GetRowParser(targetType);
             return((T)rowParser(dataReader));
         }
         return(default(T));
     }
     finally
     {
         Dispose(dataReader, isDispose);
     }
 }
コード例 #4
0
 public async Task <IEnumerable <object> > ToEnumerableAsync(RequestContext context, IDataReaderWrapper dataReader, Type targetType, bool isDispose = true)
 {
     try
     {
         IList <object> list = new List <object>();
         if (await dataReader.ReadAsync())
         {
             var rowParser = dataReader.GetRowParser(targetType);
             do
             {
                 var item = rowParser(dataReader);
                 list.Add(item);
             } while (await dataReader.ReadAsync());
         }
         return(list);
     }
     finally
     {
         Dispose(dataReader, isDispose);
     }
 }
コード例 #5
0
 public IEnumerable <object> ToEnumerable(RequestContext context, IDataReaderWrapper dataReader, Type targetType, bool isDispose = true)
 {
     try
     {
         IList <object> list = new List <object>();
         if (dataReader.Read())
         {
             var rowParser = dataReader.GetRowParser(targetType);
             do
             {
                 var target = rowParser(dataReader);
                 list.Add(target);
             } while (dataReader.Read());
         }
         return(list);
     }
     finally
     {
         Dispose(dataReader, isDispose);
     }
 }