Skip to content

Commit

Permalink
Fix DynamicQueryableExtensions for .NET 6 (#535)
Browse files Browse the repository at this point in the history
* wip

* fix

* MethodFinder

* version
  • Loading branch information
StefH authored Jul 31, 2021
1 parent 81df357 commit 2e2038d
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 88 deletions.
19 changes: 19 additions & 0 deletions System.Linq.Dynamic.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.EntityFrameworkCo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp_net5.0_EF6_InMemory", "src-console\ConsoleAppEF6_InMemory\ConsoleApp_net5.0_EF6_InMemory.csproj", "{4CC563F6-5352-4A77-A8C0-DC0D77A71DBB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp_net6.0", "src-console\ConsoleApp_net6.0\ConsoleApp_net6.0.csproj", "{C206917D-6E90-4A31-8533-AF2DD68FF738}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -702,6 +704,22 @@ Global
{4CC563F6-5352-4A77-A8C0-DC0D77A71DBB}.Release|x64.Build.0 = Release|Any CPU
{4CC563F6-5352-4A77-A8C0-DC0D77A71DBB}.Release|x86.ActiveCfg = Release|Any CPU
{4CC563F6-5352-4A77-A8C0-DC0D77A71DBB}.Release|x86.Build.0 = Release|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Debug|ARM.ActiveCfg = Debug|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Debug|ARM.Build.0 = Debug|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Debug|x64.ActiveCfg = Debug|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Debug|x64.Build.0 = Debug|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Debug|x86.ActiveCfg = Debug|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Debug|x86.Build.0 = Debug|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Release|Any CPU.Build.0 = Release|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Release|ARM.ActiveCfg = Release|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Release|ARM.Build.0 = Release|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Release|x64.ActiveCfg = Release|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Release|x64.Build.0 = Release|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Release|x86.ActiveCfg = Release|Any CPU
{C206917D-6E90-4A31-8533-AF2DD68FF738}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -742,6 +760,7 @@ Global
{3DA1CE3B-D1FB-4CEC-A4A6-22495CC36655} = {122BC4FA-7563-4E35-9D17-077F16F1629F}
{D28F6393-B56B-40A2-AF67-E8D669F42546} = {DBD7D9B6-FCC7-4650-91AF-E6457573A68F}
{4CC563F6-5352-4A77-A8C0-DC0D77A71DBB} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62}
{C206917D-6E90-4A31-8533-AF2DD68FF738} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {94C56722-194E-4B8B-BC23-B3F754E89A20}
Expand Down
15 changes: 13 additions & 2 deletions src-console/ConsoleAppEF5/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ class Program
{
static void Main(string[] args)
{
var e = new int[0].AsQueryable();
var q = new[] { 1 }.AsQueryable();

var a = q.FirstOrDefault();
// var b = e.FirstOrDefault(44); only .NET 6.0

var c = q.FirstOrDefault(i => i == 0);
// var d = q.FirstOrDefault(i => i == 0, 42); only .NET 6.0

int y = 0;

var users = new[] { new User { FirstName = "Doe" } }.AsQueryable();

var context = new TestContext();
Expand Down Expand Up @@ -102,9 +113,9 @@ static void Main(string[] args)
{
users.Select<User>(config, "new User(1 as FieldDoesNotExist)");
}
catch (Exception e)
catch (Exception ex)
{
Console.WriteLine(e);
Console.WriteLine(ex);
}

foreach (dynamic x in users.Select("new (FirstName, string(\"a\") as StrA, string('c') as StrCh, string(\"\") as StrEmpty1, string('\0') as StrEmpty2, string(null) as StrNull)"))
Expand Down
13 changes: 13 additions & 0 deletions src-console/ConsoleApp_net6.0/ConsoleApp_net6.0.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>ConsoleApp_net6._0</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\System.Linq.Dynamic.Core\System.Linq.Dynamic.Core.csproj" />
</ItemGroup>

</Project>
43 changes: 43 additions & 0 deletions src-console/ConsoleApp_net6.0/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Linq;
using System.Linq.Dynamic.Core;

namespace ConsoleApp_net6._0
{
class Program
{
static void Main(string[] args)
{
Normal();
Dynamic();

int y = 0;
}

private static void Normal()
{
var e = new int[0].AsQueryable();
var q = new[] { 1 }.AsQueryable();

var a = q.FirstOrDefault();
var b = e.FirstOrDefault(44);

var c = q.FirstOrDefault(i => i == 0);
var d = q.FirstOrDefault(i => i == 0, 42);

var t = q.Take(1);
}

private static void Dynamic()
{
var e = new int[0].AsQueryable() as IQueryable;
var q = new[] { 1 }.AsQueryable() as IQueryable;

var a = q.FirstOrDefault();
//var b = e.FirstOrDefault(44);

var c = q.FirstOrDefault("it == 0");
//var d = q.FirstOrDefault(i => i == 0, 42);
}
}
}
Loading

0 comments on commit 2e2038d

Please sign in to comment.