2
2
using System . Collections . Generic ;
3
3
using System . Linq . Dynamic . Core . Validation ;
4
4
using System . Linq . Expressions ;
5
+ using JetBrains . Annotations ;
5
6
6
7
namespace System . Linq . Dynamic . Core
7
8
{
@@ -109,7 +110,7 @@ public static int Count(this IQueryable source)
109
110
public static object Sum ( this IQueryable source )
110
111
{
111
112
Check . NotNull ( source , nameof ( source ) ) ;
112
-
113
+
113
114
return source . Provider . Execute (
114
115
Expression . Call (
115
116
typeof ( Queryable ) , "Sum" ,
@@ -261,16 +262,48 @@ public static IEnumerable<dynamic> AsEnumerable(this IQueryable source)
261
262
/// </summary>
262
263
/// <param name="source">A <see cref="IEnumerable"/> to create an array from.</param>
263
264
/// <returns>An array that contains the elements from the input sequence.</returns>
264
- public static dynamic [ ] ToDynamicArray ( this IEnumerable source )
265
-
265
+ public static dynamic [ ] ToDynamicArray ( [ NotNull ] this IEnumerable source )
266
266
{
267
+ Check . NotNull ( source , nameof ( source ) ) ;
267
268
return source . Cast < object > ( ) . ToArray ( ) ;
268
269
}
269
- #endif
270
270
271
+ /// <summary>
272
+ /// Creates a list of dynamic objects from a <see cref="IEnumerable"/>.
273
+ /// </summary>
274
+ /// <typeparam name="T"></typeparam>
275
+ /// <param name="source">A <see cref="IEnumerable"/> to create an array from.</param>
276
+ /// <returns>A Array{T} that contains the elements from the input sequence.</returns>
277
+ public static T [ ] ToDynamicArray < T > ( [ NotNull ] this IEnumerable source )
278
+ {
279
+ Check . NotNull ( source , nameof ( source ) ) ;
280
+ return source . Cast < T > ( ) . ToArray ( ) ;
281
+ }
271
282
272
- #endregion
283
+ /// <summary>
284
+ /// Creates a list of dynamic objects from a <see cref="IEnumerable"/>.
285
+ /// </summary>
286
+ /// <param name="source">A <see cref="IEnumerable"/> to create an array from.</param>
287
+ /// <returns>A List that contains the elements from the input sequence.</returns>
288
+ public static List < dynamic > ToDynamicList ( [ NotNull ] this IEnumerable source )
289
+ {
290
+ Check . NotNull ( source , nameof ( source ) ) ;
291
+ return source . Cast < object > ( ) . ToList ( ) ;
292
+ }
273
293
294
+ /// <summary>
295
+ /// Creates a list of dynamic objects from a <see cref="IEnumerable"/>.
296
+ /// </summary>
297
+ /// <typeparam name="T"></typeparam>
298
+ /// <param name="source">A <see cref="IEnumerable"/> to create an array from.</param>
299
+ /// <returns>A List{T} that contains the elements from the input sequence.</returns>
300
+ public static List < T > ToDynamicList < T > ( [ NotNull ] this IEnumerable source )
301
+ {
302
+ Check . NotNull ( source , nameof ( source ) ) ;
303
+ return source . Cast < T > ( ) . ToList ( ) ;
304
+ }
305
+ #endif
274
306
307
+ #endregion
275
308
}
276
- }
309
+ }
0 commit comments