Skip to content

Commit 6c9db9f

Browse files
committed
Add SelectMany (issue #3)
1 parent ecb5f4c commit 6c9db9f

File tree

17 files changed

+310
-205
lines changed

17 files changed

+310
-205
lines changed

src-console/System.Linq.Dynamic.Core.ConsoleTestApp.net40/Program.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections;
22
using System.Collections.Generic;
33
using System.Linq.Dynamic.Core.Tests.Helpers;
4+
using System.Linq.Dynamic.Core.Tests.Helpers.Models;
45
using System.Reflection;
56

67
namespace System.Linq.Dynamic.Core.ConsoleTestApp.net40

src-console/System.Linq.Dynamic.Core.ConsoleTestApp.net40/System.Linq.Dynamic.Core.ConsoleTestApp.net40.csproj

+14-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,20 @@
5656
<Reference Include="System.Xml" />
5757
</ItemGroup>
5858
<ItemGroup>
59-
<Compile Include="..\..\test\System.Linq.Dynamic.Core.Tests\Helpers\SampleModels.cs">
60-
<Link>Helpers\SampleModels.cs</Link>
59+
<Compile Include="..\..\test\System.Linq.Dynamic.Core.Tests\Helpers\Models\Permission.cs">
60+
<Link>Helpers\Models\Permission.cs</Link>
61+
</Compile>
62+
<Compile Include="..\..\test\System.Linq.Dynamic.Core.Tests\Helpers\Models\Role.cs">
63+
<Link>Helpers\Models\Role.cs</Link>
64+
</Compile>
65+
<Compile Include="..\..\test\System.Linq.Dynamic.Core.Tests\Helpers\Models\SimpleValuesModel.cs">
66+
<Link>Helpers\Models\SimpleValuesModel.cs</Link>
67+
</Compile>
68+
<Compile Include="..\..\test\System.Linq.Dynamic.Core.Tests\Helpers\Models\User.cs">
69+
<Link>Helpers\Models\User.cs</Link>
70+
</Compile>
71+
<Compile Include="..\..\test\System.Linq.Dynamic.Core.Tests\Helpers\Models\UserProfile.cs">
72+
<Link>Helpers\Models\UserProfile.cs</Link>
6173
</Compile>
6274
<Compile Include="..\..\test\System.Linq.Dynamic.Core.Tests\Helpers\TestEnum.cs">
6375
<Link>Helpers\TestEnum.cs</Link>

src-console/System.Linq.Dynamic.Core.ConsoleTestApp/Program.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections;
22
using System.Collections.Generic;
33
using System.Linq.Dynamic.Core.Tests.Helpers;
4+
using System.Linq.Dynamic.Core.Tests.Helpers.Models;
45
using System.Reflection;
56

67
namespace System.Linq.Dynamic.Core.ConsoleTestApp

src-console/System.Linq.Dynamic.Core.ConsoleTestApp/project.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
"compile": [
1111
"../../test/System.Linq.Dynamic.Core.Tests/Helpers/*.cs",
12+
"../../test/System.Linq.Dynamic.Core.Tests/Helpers/Models/*.cs",
1213
"../../test/System.Linq.Dynamic.Core.Tests/Helpers/Entities/Blog.cs",
1314
"../../test/System.Linq.Dynamic.Core.Tests/Helpers/Entities/Post.cs"
1415
],

src/System.Linq.Dynamic.Core/BasicQueryable.cs

+39-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq.Dynamic.Core.Validation;
44
using System.Linq.Expressions;
5+
using JetBrains.Annotations;
56

67
namespace System.Linq.Dynamic.Core
78
{
@@ -109,7 +110,7 @@ public static int Count(this IQueryable source)
109110
public static object Sum(this IQueryable source)
110111
{
111112
Check.NotNull(source, nameof(source));
112-
113+
113114
return source.Provider.Execute(
114115
Expression.Call(
115116
typeof(Queryable), "Sum",
@@ -261,16 +262,48 @@ public static IEnumerable<dynamic> AsEnumerable(this IQueryable source)
261262
/// </summary>
262263
/// <param name="source">A <see cref="IEnumerable"/> to create an array from.</param>
263264
/// <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)
266266
{
267+
Check.NotNull(source, nameof(source));
267268
return source.Cast<object>().ToArray();
268269
}
269-
#endif
270270

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+
}
271282

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+
}
273293

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
274306

307+
#endregion
275308
}
276-
}
309+
}

0 commit comments

Comments
 (0)