Beispiel #1
0
 public static object Scalar(this IQueryableCommand baseQueryBuilder)
 {
     using (var command = baseQueryBuilder.CreateCommand())
     {
         using (var reader = command.ExecuteReader())
         {
             if (!reader.Read() || reader.IsDBNull(0))
             {
                 return(null);
             }
             return(reader.GetValue(0));
         }
     }
 }
Beispiel #2
0
 public static async Task <TU> ScalarAsync <TU>(this IQueryableCommand baseQueryBuilder)
 {
     using (var command = baseQueryBuilder.CreateCommand())
     {
         using (var reader = await command.ExecuteReaderAsync())
         {
             if (!reader.Read() || reader.IsDBNull(0))
             {
                 return(default(TU));
             }
             var ret = baseQueryBuilder.Connection.Driver.ConvertReaderValueToValue(reader, typeof(TU), 0);
             return((TU)ret);
         }
     }
 }