@@ -410,7 +410,7 @@ private static long GetResultsMetadata(IList cacheable, out string[] aliases)
410
410
}
411
411
412
412
private static bool IsEmpty ( IList cacheable )
413
- // First element is the timestamp .
413
+ // First element is metadata .
414
414
=> cacheable . Count <= 1 ;
415
415
416
416
private static IEnumerable < object > GetResultsEnumerable ( IList cacheable )
@@ -427,18 +427,13 @@ private static ICacheAssembler[] GetReturnTypes(
427
427
ICacheAssembler [ ] returnTypes ,
428
428
IList cacheable )
429
429
{
430
- var hasResults = ! IsEmpty ( cacheable ) ;
431
- if ( key . ResultTransformer ? . AutoDiscoverTypes == true && hasResults )
432
- {
433
- returnTypes = GuessTypes ( cacheable ) ;
434
- }
430
+ if ( IsEmpty ( cacheable ) )
431
+ return returnTypes ;
435
432
436
- if ( hasResults && returnTypes == null )
437
- {
438
- throw new HibernateException ( "Return types for non empty query results are null, cannot assemble the results" ) ;
439
- }
433
+ if ( key . ResultTransformer ? . AutoDiscoverTypes == true )
434
+ returnTypes = GuessTypes ( cacheable ) ;
440
435
441
- return returnTypes ;
436
+ return returnTypes ?? throw new HibernateException ( "Return types for non empty query results are null, cannot assemble the results" ) ;
442
437
}
443
438
444
439
private static void PerformBeforeAssemble (
@@ -621,17 +616,20 @@ private static ICacheAssembler[] GuessTypes(IList cacheable)
621
616
foundTypes ++ ;
622
617
}
623
618
}
619
+
624
620
if ( foundTypes == colCount )
625
621
break ;
626
622
}
627
623
}
624
+
628
625
// If a column value was null for all rows, its type is still null: put a type which will just yield null
629
626
// on null value.
630
627
for ( var i = 0 ; i < colCount ; i ++ )
631
628
{
632
629
if ( returnTypes [ i ] == null )
633
630
returnTypes [ i ] = NHibernateUtil . String ;
634
631
}
632
+
635
633
return returnTypes ;
636
634
}
637
635
0 commit comments