Skip to content

Commit b1e4c14

Browse files
authored
ToDynamicListAsync uses IAsyncEnumerable (if applicable) (#620)
* wip * async * .
1 parent 6a39172 commit b1e4c14

23 files changed

+703
-623
lines changed

src-console/ConsoleAppEF6_InMemory/ConsoleApp_net6.0_EF6_InMemory.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net6.0</TargetFramework>
6+
<LangVersion>10</LangVersion>
7+
<Nullable>enable</Nullable>
68
</PropertyGroup>
79

810
<ItemGroup>

src-console/ConsoleAppEF6_InMemory/Program.cs

+31-15
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,48 @@
33
using System.Linq;
44
using System.Linq.Dynamic.Core;
55
using System.Text.Json;
6+
using System.Threading.Tasks;
67
using ConsoleAppEF2.Database;
8+
using Microsoft.EntityFrameworkCore;
79

8-
namespace ConsoleApp_net5_0_EF6_InMemory
10+
namespace ConsoleApp_net5_0_EF6_InMemory;
11+
12+
static class Program
913
{
10-
static class Program
14+
private static readonly JsonSerializerOptions JsonSerializerOptions = new() { WriteIndented = true };
15+
16+
static async Task Main(string[] args)
1117
{
12-
private readonly static JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
18+
await using (var context = new TestContextEF6())
19+
{
20+
context.Products.Add(new ProductDynamic { NullableInt = 1, Dict = new Dictionary<string, object> { { "Name", "test" } } });
21+
await context.SaveChangesAsync();
22+
}
1323

14-
static void Main(string[] args)
24+
await using (var context = new TestContextEF6())
1525
{
16-
using (var context = new TestContextEF6())
26+
var resultsNormal = context.Products.Where(p => p.Dict["Name"] == "test").ToListAsync();
27+
28+
var results1 = await context.Products.Where("Dict.Name == @0", "test").ToListAsync();
29+
Console.WriteLine("results1:");
30+
foreach (var result in results1)
1731
{
18-
context.Products.Add(new ProductDynamic { Dict = new Dictionary<string, object> { { "Name", "test" } } });
19-
context.SaveChanges();
32+
Console.WriteLine(result.Key + ":" + JsonSerializer.Serialize(result.Dict, JsonSerializerOptions));
2033
}
2134

22-
using (var context = new TestContextEF6())
35+
var results2 = await context.Products.Where("Dict.Name == @0", "test").ToDynamicListAsync();
36+
Console.WriteLine("results2:");
37+
foreach (var result in results2)
2338
{
24-
var results = context.Products.Where("Dict.Name == @0", "test");
39+
Console.WriteLine(result.Key + ":" + JsonSerializer.Serialize(result.Dict, JsonSerializerOptions));
40+
}
2541

26-
Console.WriteLine("results = ?");
27-
foreach (var result in results)
28-
{
29-
Console.WriteLine(result.Key + JsonSerializer.Serialize(result.Dict, JsonSerializerOptions));
30-
}
42+
var results3 = await context.Products.Where("NullableInt == 1").ToDynamicListAsync(typeof(ProductDynamic));
43+
Console.WriteLine("results3:");
44+
foreach (var result in results3)
45+
{
46+
Console.WriteLine(result.Key + ":" + JsonSerializer.Serialize(result.Dict, JsonSerializerOptions));
3147
}
3248
}
3349
}
34-
}
50+
}

src/EntityFramework.DynamicLinq/EntityFramework.DynamicLinq.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2727
<Company>ZZZ Projects</Company>
2828
<Copyright>Copyright © ZZZ Projects</Copyright>
29+
<LangVersion>10</LangVersion>
30+
<Nullable>enable</Nullable>
2931
</PropertyGroup>
3032

3133
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore2/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore2.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2727
<Company>ZZZ Projects</Company>
2828
<Copyright>Copyright © ZZZ Projects</Copyright>
29+
<LangVersion>10</LangVersion>
30+
<Nullable>enable</Nullable>
2931
</PropertyGroup>
3032

3133
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<AssemblyTitle>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyTitle>
88
<Authors>ZZZ Projects;Stef Heyenrath</Authors>
99
<TargetFrameworks>netstandard2.0</TargetFrameworks>
10-
<DefineConstants>$(DefineConstants);EFCORE;EFCORE_3X;EFDYNAMICFUNCTIONS</DefineConstants>
10+
<DefineConstants>$(DefineConstants);EFCORE;EFCORE_3X;EFDYNAMICFUNCTIONS;ASYNCENUMERABLE</DefineConstants>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1212
<AssemblyName>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyName>
1313
<AssemblyOriginatorKeyFile>../Microsoft.EntityFrameworkCore.DynamicLinq.EFCore2/Microsoft.EntityFrameworkCore.DynamicLinq.snk</AssemblyOriginatorKeyFile>
@@ -26,6 +26,8 @@
2626
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2727
<Company>ZZZ Projects</Company>
2828
<Copyright>Copyright © ZZZ Projects</Copyright>
29+
<LangVersion>10</LangVersion>
30+
<Nullable>enable</Nullable>
2931
</PropertyGroup>
3032

3133
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore5/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore5.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<AssemblyTitle>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyTitle>
88
<Authors>ZZZ Projects;Stef Heyenrath</Authors>
99
<TargetFrameworks>netstandard2.1;net5.0</TargetFrameworks>
10-
<DefineConstants>$(DefineConstants);EFCORE;EFCORE_3X;EFDYNAMICFUNCTIONS</DefineConstants>
10+
<DefineConstants>$(DefineConstants);EFCORE;EFCORE_3X;EFDYNAMICFUNCTIONS;ASYNCENUMERABLE</DefineConstants>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1212
<AssemblyName>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyName>
1313
<AssemblyOriginatorKeyFile>../Microsoft.EntityFrameworkCore.DynamicLinq.EFCore2/Microsoft.EntityFrameworkCore.DynamicLinq.snk</AssemblyOriginatorKeyFile>
@@ -26,6 +26,8 @@
2626
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2727
<Company>ZZZ Projects</Company>
2828
<Copyright>Copyright © ZZZ Projects</Copyright>
29+
<LangVersion>10</LangVersion>
30+
<Nullable>enable</Nullable>
2931
</PropertyGroup>
3032

3133
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore6/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore6.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<AssemblyTitle>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyTitle>
88
<Authors>ZZZ Projects;Stef Heyenrath</Authors>
99
<TargetFrameworks>net6.0</TargetFrameworks>
10-
<DefineConstants>$(DefineConstants);EFCORE;EFCORE_3X;EFDYNAMICFUNCTIONS</DefineConstants>
10+
<DefineConstants>$(DefineConstants);EFCORE;EFCORE_3X;EFDYNAMICFUNCTIONS;ASYNCENUMERABLE</DefineConstants>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1212
<AssemblyName>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyName>
1313
<AssemblyOriginatorKeyFile>../Microsoft.EntityFrameworkCore.DynamicLinq.EFCore2/Microsoft.EntityFrameworkCore.DynamicLinq.snk</AssemblyOriginatorKeyFile>
@@ -26,6 +26,8 @@
2626
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2727
<Company>ZZZ Projects</Company>
2828
<Copyright>Copyright © ZZZ Projects</Copyright>
29+
<LangVersion>10</LangVersion>
30+
<Nullable>enable</Nullable>
2931
</PropertyGroup>
3032

3133
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
#if NET35
22
namespace System
33
{
4+
/// <summary>
5+
/// Represents a 2-tuple, or pair.
6+
/// </summary>
7+
/// <typeparam name="T1">The type of the tuple's first component.</typeparam>
8+
/// <typeparam name="T2">The type of the tuple's second component.</typeparam>
49
public class Tuple<T1, T2>
510
{
11+
/// <summary>
12+
/// The value of the current System.Tuple`2 object's first component.
13+
/// </summary>
614
public T1 Item1 { get; private set; }
15+
16+
/// <summary>
17+
/// The value of the current System.Tuple`2 object's second component.
18+
/// </summary>
719
public T2 Item2 { get; private set; }
820

921
internal Tuple(T1 item1, T2 item2)
@@ -13,5 +25,4 @@ internal Tuple(T1 item1, T2 item2)
1325
}
1426
}
1527
}
16-
17-
#endif
28+
#endif

0 commit comments

Comments
 (0)