Skip to content

Commit

Permalink
Fix FindIndexer
Browse files Browse the repository at this point in the history
Linked to #57
  • Loading branch information
StefH committed Dec 7, 2016
1 parent 40a7e5f commit bd16c89
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/System.Linq.Dynamic.Core/ExpressionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1682,11 +1682,11 @@ int FindIndexer(Type type, Expression[] args, out MethodBase method)
{
foreach (Type t in SelfAndBaseTypes(type))
{
#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)
//#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)
MemberInfo[] members = t.GetDefaultMembers();
#else
MemberInfo[] members = new MemberInfo[0];
#endif
//#else
// MemberInfo[] members = new MemberInfo[0];
//#endif
if (members.Length != 0)
{
IEnumerable<MethodBase> methods = members
Expand Down
18 changes: 18 additions & 0 deletions test/System.Linq.Dynamic.Core.Tests/ExpressionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq.Dynamic.Core.Exceptions;
using System.Linq.Dynamic.Core.Tests.Helpers;
using System.Linq.Dynamic.Core.Tests.Helpers.Models;
using Newtonsoft.Json.Linq;
using Xunit;

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

[Fact]
public void ExpressionTests_Indexer_Issue57()
{
var rows = new List<JObject>
{
new JObject {["Column1"] = "B", ["Column2"] = 1},
new JObject {["Column1"] = "B", ["Column2"] = 2},
new JObject {["Column1"] = "A", ["Column2"] = 1},
new JObject {["Column1"] = "A", ["Column2"] = 2}
};

var expected = rows.OrderBy(x => x["Column1"]).ToList();
var result = rows.AsQueryable().OrderBy(@"it[""Column1""]").ToList();

Assert.Equal(expected, result);
}

[Fact]
public void ExpressionTests_IntegerQualifiers()
{
Expand Down
69 changes: 35 additions & 34 deletions test/System.Linq.Dynamic.Core.Tests/project.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
{
"version": "1.0.0-*",
"authors": [ "Stef Heyenrath" ],
"dependencies": {
"Linq.PropertyTranslator.Core": "1.0.3",
"QueryInterceptor.Core": "1.0.3",
"System.AppDomain.NetCoreApp": "1.0.1",
"System.Linq.Dynamic.Core": { "target": "project" },
"Microsoft.EntityFrameworkCore.DynamicLinq": { "target": "project" },
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"xunit": "2.2.0-beta2-build3300"
},
"version": "1.0.0-*",
"authors": [ "Stef Heyenrath" ],
"dependencies": {
"Newtonsoft.Json": "9.0.1",
"Linq.PropertyTranslator.Core": "1.0.3",
"QueryInterceptor.Core": "1.0.5",
"System.AppDomain.NetCoreApp": "1.0.1",
"System.Linq.Dynamic.Core": { "target": "project" },
"Microsoft.EntityFrameworkCore.DynamicLinq": { "target": "project" },
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"xunit": "2.2.0-beta2-build3300"
},

"frameworks": {
"netcoreapp1.0": {
"buildOptions": { "define": [ "NETSTANDARD", "EFCORE" ] },
"imports": [
"dnxcore50",
"dotnet5.4",
"portable-net451+win8"
],
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
},
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.Sqlite": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"System.Linq.Parallel": "4.3.0",
"System.Threading.Tasks": "4.3.0"
}
}
},
"frameworks": {
"netcoreapp1.0": {
"buildOptions": { "define": [ "NETSTANDARD", "EFCORE" ] },
"imports": [
"dnxcore50",
"dotnet5.4",
"portable-net451+win8"
],
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
},
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.Sqlite": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"System.Linq.Parallel": "4.3.0",
"System.Threading.Tasks": "4.3.0"
}
}
},

"testRunner": "xunit"
"testRunner": "xunit"
}

0 comments on commit bd16c89

Please sign in to comment.