Skip to content

Commit bd16c89

Browse files
committed
Fix FindIndexer
Linked to #57
1 parent 40a7e5f commit bd16c89

File tree

3 files changed

+57
-38
lines changed

3 files changed

+57
-38
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -1682,11 +1682,11 @@ int FindIndexer(Type type, Expression[] args, out MethodBase method)
16821682
{
16831683
foreach (Type t in SelfAndBaseTypes(type))
16841684
{
1685-
#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)
1685+
//#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)
16861686
MemberInfo[] members = t.GetDefaultMembers();
1687-
#else
1688-
MemberInfo[] members = new MemberInfo[0];
1689-
#endif
1687+
//#else
1688+
// MemberInfo[] members = new MemberInfo[0];
1689+
//#endif
16901690
if (members.Length != 0)
16911691
{
16921692
IEnumerable<MethodBase> methods = members

test/System.Linq.Dynamic.Core.Tests/ExpressionTests.cs

+18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq.Dynamic.Core.Exceptions;
44
using System.Linq.Dynamic.Core.Tests.Helpers;
55
using System.Linq.Dynamic.Core.Tests.Helpers.Models;
6+
using Newtonsoft.Json.Linq;
67
using Xunit;
78

89
namespace System.Linq.Dynamic.Core.Tests
@@ -496,6 +497,23 @@ public void ExpressionTests_IsNull_Complex()
496497
Assert.Equal(expectedResult3, result3b.ToDynamicArray<int>());
497498
}
498499

500+
[Fact]
501+
public void ExpressionTests_Indexer_Issue57()
502+
{
503+
var rows = new List<JObject>
504+
{
505+
new JObject {["Column1"] = "B", ["Column2"] = 1},
506+
new JObject {["Column1"] = "B", ["Column2"] = 2},
507+
new JObject {["Column1"] = "A", ["Column2"] = 1},
508+
new JObject {["Column1"] = "A", ["Column2"] = 2}
509+
};
510+
511+
var expected = rows.OrderBy(x => x["Column1"]).ToList();
512+
var result = rows.AsQueryable().OrderBy(@"it[""Column1""]").ToList();
513+
514+
Assert.Equal(expected, result);
515+
}
516+
499517
[Fact]
500518
public void ExpressionTests_IntegerQualifiers()
501519
{
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
11
{
2-
"version": "1.0.0-*",
3-
"authors": [ "Stef Heyenrath" ],
4-
"dependencies": {
5-
"Linq.PropertyTranslator.Core": "1.0.3",
6-
"QueryInterceptor.Core": "1.0.3",
7-
"System.AppDomain.NetCoreApp": "1.0.1",
8-
"System.Linq.Dynamic.Core": { "target": "project" },
9-
"Microsoft.EntityFrameworkCore.DynamicLinq": { "target": "project" },
10-
"dotnet-test-xunit": "2.2.0-preview2-build1029",
11-
"xunit": "2.2.0-beta2-build3300"
12-
},
2+
"version": "1.0.0-*",
3+
"authors": [ "Stef Heyenrath" ],
4+
"dependencies": {
5+
"Newtonsoft.Json": "9.0.1",
6+
"Linq.PropertyTranslator.Core": "1.0.3",
7+
"QueryInterceptor.Core": "1.0.5",
8+
"System.AppDomain.NetCoreApp": "1.0.1",
9+
"System.Linq.Dynamic.Core": { "target": "project" },
10+
"Microsoft.EntityFrameworkCore.DynamicLinq": { "target": "project" },
11+
"dotnet-test-xunit": "2.2.0-preview2-build1029",
12+
"xunit": "2.2.0-beta2-build3300"
13+
},
1314

14-
"frameworks": {
15-
"netcoreapp1.0": {
16-
"buildOptions": { "define": [ "NETSTANDARD", "EFCORE" ] },
17-
"imports": [
18-
"dnxcore50",
19-
"dotnet5.4",
20-
"portable-net451+win8"
21-
],
22-
"dependencies": {
23-
"Microsoft.NETCore.App": {
24-
"type": "platform",
25-
"version": "1.0.1"
26-
},
27-
"Microsoft.EntityFrameworkCore": "1.1.0",
28-
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
29-
"Microsoft.EntityFrameworkCore.Sqlite": "1.1.0",
30-
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
31-
"System.Linq.Parallel": "4.3.0",
32-
"System.Threading.Tasks": "4.3.0"
33-
}
34-
}
35-
},
15+
"frameworks": {
16+
"netcoreapp1.0": {
17+
"buildOptions": { "define": [ "NETSTANDARD", "EFCORE" ] },
18+
"imports": [
19+
"dnxcore50",
20+
"dotnet5.4",
21+
"portable-net451+win8"
22+
],
23+
"dependencies": {
24+
"Microsoft.NETCore.App": {
25+
"type": "platform",
26+
"version": "1.0.1"
27+
},
28+
"Microsoft.EntityFrameworkCore": "1.1.0",
29+
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
30+
"Microsoft.EntityFrameworkCore.Sqlite": "1.1.0",
31+
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
32+
"System.Linq.Parallel": "4.3.0",
33+
"System.Threading.Tasks": "4.3.0"
34+
}
35+
}
36+
},
3637

37-
"testRunner": "xunit"
38+
"testRunner": "xunit"
3839
}

0 commit comments

Comments
 (0)