@@ -106,7 +106,7 @@ public void GroupInterval_Numeric() {
106106
107107 string Compile < T > ( string selector , bool guardNulls ) {
108108 var compiler = new RemoteGroupExpressionCompiler < T > (
109- guardNulls , null ,
109+ guardNulls , false , null ,
110110 new [ ] {
111111 new GroupingInfo { Selector = selector , GroupInterval = "123" }
112112 } ,
@@ -130,7 +130,7 @@ public void GroupInterval_Date() {
130130
131131 string Compile < T > ( string selector , bool guardNulls ) {
132132 var compiler = new RemoteGroupExpressionCompiler < T > (
133- guardNulls , null ,
133+ guardNulls , false , null ,
134134 new [ ] {
135135 new GroupingInfo { Selector = selector , GroupInterval = "year" } ,
136136 new GroupingInfo { Selector = selector , GroupInterval = "quarter" } ,
@@ -216,6 +216,52 @@ void Bug100Core<T>(params string[] memberNames) {
216216 ) ;
217217 }
218218
219+ [ Fact ]
220+ public void GetSumType_ExpandFalse ( ) {
221+ Type GetSumType < T > ( ) => RemoteGroupExpressionCompiler < object > . GetSumType ( typeof ( T ) , false ) ;
222+
223+ // Validation: check lambda type in new T[0].Sum(i => i)
224+
225+ Assert . Equal ( typeof ( int ) , GetSumType < sbyte > ( ) ) ;
226+ Assert . Equal ( typeof ( int ) , GetSumType < byte > ( ) ) ;
227+
228+ Assert . Equal ( typeof ( int ) , GetSumType < short > ( ) ) ;
229+ Assert . Equal ( typeof ( int ) , GetSumType < ushort > ( ) ) ;
230+
231+ Assert . Equal ( typeof ( int ) , GetSumType < int > ( ) ) ;
232+ Assert . Equal ( typeof ( long ) , GetSumType < uint > ( ) ) ;
233+
234+ Assert . Equal ( typeof ( long ) , GetSumType < long > ( ) ) ;
235+ Assert . Equal ( typeof ( decimal ) , GetSumType < ulong > ( ) ) ;
236+
237+ Assert . Equal ( typeof ( float ) , GetSumType < float > ( ) ) ;
238+ Assert . Equal ( typeof ( double ) , GetSumType < double > ( ) ) ;
239+ Assert . Equal ( typeof ( decimal ) , GetSumType < decimal > ( ) ) ;
240+ }
241+
242+ [ Fact ]
243+ public void GetSumType_ExpandTrue ( ) {
244+ Type GetSumType < T > ( ) => RemoteGroupExpressionCompiler < object > . GetSumType ( typeof ( T ) , true ) ;
245+
246+ // Don't convert integer types to decimal because SQL decimals have variable precision
247+ // Except for UInt64 for which there is no better choice
248+
249+ Assert . Equal ( typeof ( long ) , GetSumType < sbyte > ( ) ) ;
250+ Assert . Equal ( typeof ( long ) , GetSumType < byte > ( ) ) ;
251+
252+ Assert . Equal ( typeof ( long ) , GetSumType < short > ( ) ) ;
253+ Assert . Equal ( typeof ( long ) , GetSumType < ushort > ( ) ) ;
254+
255+ Assert . Equal ( typeof ( long ) , GetSumType < int > ( ) ) ;
256+ Assert . Equal ( typeof ( long ) , GetSumType < uint > ( ) ) ;
257+
258+ Assert . Equal ( typeof ( long ) , GetSumType < long > ( ) ) ;
259+ Assert . Equal ( typeof ( decimal ) , GetSumType < ulong > ( ) ) ;
260+
261+ Assert . Equal ( typeof ( double ) , GetSumType < float > ( ) ) ;
262+ Assert . Equal ( typeof ( double ) , GetSumType < double > ( ) ) ;
263+ Assert . Equal ( typeof ( decimal ) , GetSumType < decimal > ( ) ) ;
264+ }
219265 }
220266
221267}
0 commit comments