Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Json support #791

Open
wants to merge 71 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f60736f
JArray
StefH Apr 8, 2024
7f4f273
...
StefH Apr 8, 2024
5ea2d44
Select
StefH Apr 8, 2024
4a97bee
.
StefH Apr 8, 2024
33a5ecc
tests
StefH Apr 8, 2024
2761151
fix tst
StefH Apr 8, 2024
db3fabe
CI
StefH Apr 8, 2024
ef538b8
net35;
StefH Apr 8, 2024
d0875b9
---
StefH Apr 8, 2024
0855867
????????????
StefH Apr 8, 2024
e57d6ed
stj
StefH Apr 9, 2024
23faa1e
Run Json Tests .NET 8
StefH Apr 9, 2024
f444795
any
StefH Apr 9, 2024
08b5274
Aggregate
StefH Apr 9, 2024
b3c597a
where-select tests
StefH Apr 9, 2024
ac11701
Average
StefH Apr 9, 2024
c03037b
Cast
StefH Apr 9, 2024
53b7ab3
Count
StefH Apr 9, 2024
9080f0c
Distinct
StefH Apr 9, 2024
e658558
First
StefH Apr 9, 2024
1c25fe2
FirstOrDefault
StefH Apr 9, 2024
bf2e7fa
Last
StefH Apr 9, 2024
9f074d0
LastOrDefault
StefH Apr 9, 2024
aa60751
Max / Min
StefH Apr 9, 2024
d56b0d3
OrderBy
StefH Apr 9, 2024
4110470
Page
StefH Apr 10, 2024
ab3f627
.
StefH Apr 10, 2024
680c879
Select_ResultType
StefH Apr 10, 2024
8677ab5
Single / SingleOrDefault
StefH Apr 10, 2024
cf34f09
Skip
StefH Apr 10, 2024
775788a
min max
StefH Apr 10, 2024
8dc72ef
Take
StefH Apr 10, 2024
39e9e79
OrderBy_ThenBy
StefH Apr 10, 2024
e8b4074
Where
StefH Apr 10, 2024
82004ff
.
StefH Apr 10, 2024
b0b7fd5
DynamicClassFactory.CreateInstance
StefH Apr 10, 2024
11259d8
Merge branch 'master' into stef-789-json
StefH Apr 11, 2024
44cc5a8
Update JsonDocumentExtensions.cs
StefH Apr 11, 2024
88dfcfb
Merge branch 'master' into stef-789-json
StefH Apr 13, 2024
6fc0f81
fix compile errors (#797)
paule96 Apr 15, 2024
2b7ef03
some updates
StefH Apr 15, 2024
5e8025e
Merge branch 'master' into stef-789-json
StefH Apr 17, 2024
fa2b32c
Merge branch 'master' into stef-789-json
StefH Apr 17, 2024
8cbe542
Merge branch 'master' into stef-789-json
StefH Apr 18, 2024
6cb4317
1.4
StefH Apr 23, 2024
a79b394
Merge branch 'master' into stef-789-json
StefH Apr 23, 2024
a4c978d
.
StefH Apr 28, 2024
73f6c70
mm
StefH May 3, 2024
fdd3c36
"""
StefH May 7, 2024
ca28c5d
merge from master
StefH May 31, 2024
b0eccbc
@
StefH Jun 15, 2024
b59bd3c
remove ThenBy
StefH Jun 15, 2024
aa0602d
mm
StefH Jun 18, 2024
94b927b
mm
StefH Jun 24, 2024
dbc2e4e
CI json
StefH Jun 24, 2024
8ed2a6e
csproj / --framework net8.0
StefH Jun 24, 2024
b37b515
more tests
StefH Jun 24, 2024
ca50f63
float
StefH Jun 24, 2024
fa559ec
mv
StefH Jun 24, 2024
62e4ba1
Merge branch 'master' into stef-789-json
StefH Jun 25, 2024
12946cc
Merge branch 'master' into stef-789-json
StefH Jun 26, 2024
ddf6712
Merge branch 'master' into stef-789-json
StefH Jul 1, 2024
d67d295
...
StefH Jul 12, 2024
26ab6f7
merge from main
StefH Aug 21, 2024
9203f6d
...
StefH Aug 21, 2024
6d0ea83
mm
StefH Aug 26, 2024
ebde7ca
fix
StefH Aug 26, 2024
3beedca
Merge branch 'master' into stef-789-json
StefH Oct 12, 2024
6c7c513
7
StefH Oct 12, 2024
0fa3109
mm
StefH Oct 13, 2024
24c6570
mm
StefH Oct 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ jobs:
- name: Run Tests EFCore net8.0 (with Coverage)
run: |
dotnet-coverage collect 'dotnet test ./test/System.Linq.Dynamic.Core.Tests/System.Linq.Dynamic.Core.Tests.csproj --configuration Debug -p:buildType=azure-pipelines-ci' -f xml -o dynamic-coverage-efcore.xml

- name: Run Tests Json .NET 8 (with Coverage)
run: |
dotnet-coverage collect 'dotnet test ./test/System.Linq.Dynamic.Core.NewtonsoftJson.Tests/System.Linq.Dynamic.Core.NewtonsoftJson.Tests.csproj --configuration Debug --framework net8.0 -p:buildType=azure-pipelines-ci' -f xml -o dynamic-coverage-newtonsoftjson.xml
dotnet-coverage collect 'dotnet test ./test/System.Linq.Dynamic.Core.SystemTextJson.Tests/System.Linq.Dynamic.Core.SystemTextJson.Tests.csproj --configuration Debug --framework net8.0 -p:buildType=azure-pipelines-ci' -f xml -o dynamic-coverage-systemtextjson.xml

- name: End analysis on SonarCloud
if: ${{ steps.secret-check.outputs.run_analysis == 'true' }}
Expand Down
76 changes: 76 additions & 0 deletions System.Linq.Dynamic.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo.Plugin", "src-console\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Dynamic.Core.Tests.NetCoreApp31", "test\System.Linq.Dynamic.Core.Tests.NetCoreApp31\System.Linq.Dynamic.Core.Tests.NetCoreApp31.csproj", "{7AFC2836-0F6E-4B0D-8BB3-13317A3B6616}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Dynamic.Core.NewtonsoftJson", "src\System.Linq.Dynamic.Core.NewtonsoftJson\System.Linq.Dynamic.Core.NewtonsoftJson.csproj", "{8C5851B8-5C47-4229-AB55-D4252703598E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Dynamic.Core.NewtonsoftJson.Tests", "test\System.Linq.Dynamic.Core.NewtonsoftJson.Tests\System.Linq.Dynamic.Core.NewtonsoftJson.Tests.csproj", "{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Dynamic.Core.SystemTextJson", "src\System.Linq.Dynamic.Core.SystemTextJson\System.Linq.Dynamic.Core.SystemTextJson.csproj", "{FA01CE15-315A-499E-AFC2-955CA7EB45FF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Dynamic.Core.SystemTextJson.Tests", "test\System.Linq.Dynamic.Core.SystemTextJson.Tests\System.Linq.Dynamic.Core.SystemTextJson.Tests.csproj", "{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WasmDynamicLinq", "src-blazor\WasmDynamicLinq\WasmDynamicLinq.csproj", "{2DE2052F-0A50-40C7-B6FF-52B52386BF9A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SldcTrimmer", "src-examples\SldcTrimmer\SldcTrimmer.csproj", "{7A31366C-DD98-41A3-A0C1-A97068BD9658}"
Expand Down Expand Up @@ -899,6 +907,70 @@ Global
{7AFC2836-0F6E-4B0D-8BB3-13317A3B6616}.Release|x64.Build.0 = Release|Any CPU
{7AFC2836-0F6E-4B0D-8BB3-13317A3B6616}.Release|x86.ActiveCfg = Release|Any CPU
{7AFC2836-0F6E-4B0D-8BB3-13317A3B6616}.Release|x86.Build.0 = Release|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Debug|ARM.Build.0 = Debug|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Debug|x64.ActiveCfg = Debug|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Debug|x64.Build.0 = Debug|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Debug|x86.ActiveCfg = Debug|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Debug|x86.Build.0 = Debug|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Release|Any CPU.Build.0 = Release|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Release|ARM.ActiveCfg = Release|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Release|ARM.Build.0 = Release|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Release|x64.ActiveCfg = Release|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Release|x64.Build.0 = Release|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Release|x86.ActiveCfg = Release|Any CPU
{8C5851B8-5C47-4229-AB55-D4252703598E}.Release|x86.Build.0 = Release|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Debug|Any CPU.Build.0 = Debug|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Debug|ARM.ActiveCfg = Debug|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Debug|ARM.Build.0 = Debug|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Debug|x64.ActiveCfg = Debug|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Debug|x64.Build.0 = Debug|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Debug|x86.ActiveCfg = Debug|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Debug|x86.Build.0 = Debug|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Release|Any CPU.ActiveCfg = Release|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Release|Any CPU.Build.0 = Release|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Release|ARM.ActiveCfg = Release|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Release|ARM.Build.0 = Release|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Release|x64.ActiveCfg = Release|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Release|x64.Build.0 = Release|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Release|x86.ActiveCfg = Release|Any CPU
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90}.Release|x86.Build.0 = Release|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Debug|ARM.ActiveCfg = Debug|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Debug|ARM.Build.0 = Debug|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Debug|x64.ActiveCfg = Debug|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Debug|x64.Build.0 = Debug|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Debug|x86.ActiveCfg = Debug|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Debug|x86.Build.0 = Debug|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Release|Any CPU.Build.0 = Release|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Release|ARM.ActiveCfg = Release|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Release|ARM.Build.0 = Release|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Release|x64.ActiveCfg = Release|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Release|x64.Build.0 = Release|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Release|x86.ActiveCfg = Release|Any CPU
{FA01CE15-315A-499E-AFC2-955CA7EB45FF}.Release|x86.Build.0 = Release|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Debug|ARM.Build.0 = Debug|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Debug|x64.ActiveCfg = Debug|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Debug|x64.Build.0 = Debug|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Debug|x86.ActiveCfg = Debug|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Debug|x86.Build.0 = Debug|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Release|Any CPU.Build.0 = Release|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Release|ARM.ActiveCfg = Release|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Release|ARM.Build.0 = Release|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Release|x64.ActiveCfg = Release|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Release|x64.Build.0 = Release|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Release|x86.ActiveCfg = Release|Any CPU
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E}.Release|x86.Build.0 = Release|Any CPU
{2DE2052F-0A50-40C7-B6FF-52B52386BF9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2DE2052F-0A50-40C7-B6FF-52B52386BF9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DE2052F-0A50-40C7-B6FF-52B52386BF9A}.Debug|ARM.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -982,6 +1054,10 @@ Global
{D8368319-F370-4071-9411-A3DADB234330} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62}
{B01B327C-FC68-49B6-BDE3-A13D0C66DF5C} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62}
{7AFC2836-0F6E-4B0D-8BB3-13317A3B6616} = {8463ED7E-69FB-49AE-85CF-0791AFD98E38}
{8C5851B8-5C47-4229-AB55-D4252703598E} = {DBD7D9B6-FCC7-4650-91AF-E6457573A68F}
{912FBF24-3CAE-4A50-B5EA-E525B9FAEC90} = {8463ED7E-69FB-49AE-85CF-0791AFD98E38}
{FA01CE15-315A-499E-AFC2-955CA7EB45FF} = {DBD7D9B6-FCC7-4650-91AF-E6457573A68F}
{D5844AE4-53FA-4C8A-9D52-AD213FD0CA1E} = {8463ED7E-69FB-49AE-85CF-0791AFD98E38}
{2DE2052F-0A50-40C7-B6FF-52B52386BF9A} = {122BC4FA-7563-4E35-9D17-077F16F1629F}
{7A31366C-DD98-41A3-A0C1-A97068BD9658} = {BCA2A024-9032-4E56-A6C4-17A15D921728}
EndGlobalSection
Expand Down
3 changes: 2 additions & 1 deletion src-console/ConsoleApp_net6.0/ConsoleApp_net6.0.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
</PropertyGroup>

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

</Project>
225 changes: 147 additions & 78 deletions src-console/ConsoleApp_net6.0/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,116 +2,185 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Linq.Dynamic.Core.Parser;
using System.Linq.Dynamic.Core.NewtonsoftJson;
using System.Linq.Dynamic.Core.SystemTextJson;
using System.Linq.Expressions;
using System.Text.Json;
using Newtonsoft.Json.Linq;

namespace ConsoleApp_net6._0
namespace ConsoleApp_net6._0;

public class X
{
public class X
{
public string Key { get; set; } = null!;
public string Key { get; set; } = null!;

public List<Y>? Contestants { get; set; }
}
public List<Y>? Contestants { get; set; }
}

public class Y
public class Y
{
}

class Program
{
static void Main(string[] args)
{
Json();
NewtonsoftJson();

return;

Issue389DoesNotWork();
return;
Issue389_Works();
return;

var q = new[]
{
new X { Key = "x" },
new X { Key = "a" },
new X { Key = "a", Contestants = new List<Y> { new Y() } }
}.AsQueryable();
var groupByKey = q.GroupBy("Key");
var selectQry = groupByKey.Select("new (Key, Sum(np(Contestants.Count, 0)) As TotalCount)").ToDynamicList();

Normal();
Dynamic();
}

class Program
private static void NewtonsoftJson()
{
static void Main(string[] args)
var array = JArray.Parse(@"[
{
var parser = new ExpressionParser(new[] { Expression.Parameter(typeof(int), "VarA") }, "\"foo\" & VarA", new object[0], new ParsingConfig { ConvertObjectToSupportComparison = true});

var expression = parser.Parse(typeof(string));

Issue389DoesNotWork();
return;
Issue389_Works();
return;

var q = new[]
{
new X { Key = "x" },
new X { Key = "a" },
new X { Key = "a", Contestants = new List<Y> { new Y() } }
}.AsQueryable();
var groupByKey = q.GroupBy("Key");
var selectQry = groupByKey.Select("new (Key, Sum(np(Contestants.Count, 0)) As TotalCount)").ToDynamicList();

Normal();
Dynamic();
}

private static void Issue389_Works()
""first"": 1,
""City"": ""Paris"",
""third"": ""test""
},
{
var strArray = new[] { "1", "2", "3", "4" };
var x = new List<ParameterExpression>();
x.Add(Expression.Parameter(strArray.GetType(), "strArray"));
""first"": 2,
""City"": ""New York"",
""third"": ""abc""
}]");

string query = "string.Join(\",\", strArray)";
var where = array.Where("City == @0", "Paris");
foreach (var result in where)
{
Console.WriteLine(result["first"]);
}

var e = DynamicExpressionParser.ParseLambda(x.ToArray(), null, query);
Delegate del = e.Compile();
var result1 = del.DynamicInvoke(new object?[] { strArray });
Console.WriteLine(result1);
var select = array.Select("City");
foreach (var result in select)
{
Console.WriteLine(result);
}

private static void Issue389WorksWithInts()
var whereWithSelect = array.Where("City == @0", "Paris").Select("first");
foreach (var result in whereWithSelect)
{
var intArray = new object[] { 1, 2, 3, 4 };
var x = new List<ParameterExpression>();
x.Add(Expression.Parameter(intArray.GetType(), "intArray"));
Console.WriteLine(result);
}
}

string query = "string.Join(\",\", intArray)";
private static void Json()
{
var doc = JsonDocument.Parse(@"[
{
""first"": 1,
""City"": ""Paris"",
""third"": ""test""
},
{
""first"": 2,
""City"": ""New York"",
""third"": ""abc""
}]");

var e = DynamicExpressionParser.ParseLambda(x.ToArray(), null, query);
Delegate del = e.Compile();
var result = del.DynamicInvoke(new object?[] { intArray });
var where = doc.Where("City == @0", "Paris");
foreach (var result in where.RootElement.EnumerateArray())
{
Console.WriteLine(result.GetProperty("first"));
}

var select = doc.Select("City");
foreach (var result in select.RootElement.EnumerateArray())
{
Console.WriteLine(result);
}

private static void Issue389DoesNotWork()
var whereWithSelect = doc.Where("City == @0", "Paris").Select("first");
foreach (var result in whereWithSelect.RootElement.EnumerateArray())
{
var intArray = new [] { 1, 2, 3, 4 };
var x = new List<ParameterExpression>();
x.Add(Expression.Parameter(intArray.GetType(), "intArray"));
Console.WriteLine(result);
}
}

string query = "string.Join(\",\", intArray)";
private static void Issue389_Works()
{
var strArray = new[] { "1", "2", "3", "4" };
var x = new List<ParameterExpression>();
x.Add(Expression.Parameter(strArray.GetType(), "strArray"));

var e = DynamicExpressionParser.ParseLambda(x.ToArray(), null, query);
Delegate del = e.Compile();
var result = del.DynamicInvoke(new object?[] { intArray });
string query = "string.Join(\",\", strArray)";

Console.WriteLine(result);
}
var e = DynamicExpressionParser.ParseLambda(x.ToArray(), null, query);
Delegate del = e.Compile();
var result1 = del.DynamicInvoke(new object?[] { strArray });
Console.WriteLine(result1);
}

private static void Normal()
{
var e = new int[0].AsQueryable();
var q = new[] { 1 }.AsQueryable();
private static void Issue389WorksWithInts()
{
var intArray = new object[] { 1, 2, 3, 4 };
var x = new List<ParameterExpression>();
x.Add(Expression.Parameter(intArray.GetType(), "intArray"));

var a = q.FirstOrDefault();
var b = e.FirstOrDefault(44);
string query = "string.Join(\",\", intArray)";

var c = q.FirstOrDefault(i => i == 0);
var d = q.FirstOrDefault(i => i == 0, 42);
var e = DynamicExpressionParser.ParseLambda(x.ToArray(), null, query);
Delegate del = e.Compile();
var result = del.DynamicInvoke(new object?[] { intArray });

var t = q.Take(1);
}
Console.WriteLine(result);
}

private static void Dynamic()
{
var e = new int[0].AsQueryable() as IQueryable;
var q = new[] { 1 }.AsQueryable() as IQueryable;
private static void Issue389DoesNotWork()
{
var intArray = new[] { 1, 2, 3, 4 };
var x = new List<ParameterExpression>();
x.Add(Expression.Parameter(intArray.GetType(), "intArray"));

var a = q.FirstOrDefault();
//var b = e.FirstOrDefault(44);
string query = "string.Join(\",\", intArray)";

var c = q.FirstOrDefault("it == 0");
//var d = q.FirstOrDefault(i => i == 0, 42);
}
var e = DynamicExpressionParser.ParseLambda(x.ToArray(), null, query);
Delegate del = e.Compile();
var result = del.DynamicInvoke(new object?[] { intArray });

Console.WriteLine(result);
}

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