Skip to content

Commit 3eb32ba

Browse files
Compatibility with System.Linq.Dynamic.Core dynamic classes (#334)
1 parent e3c3e88 commit 3eb32ba

5 files changed

Lines changed: 27 additions & 1 deletion

File tree

net/DevExtreme.AspNet.Data.Tests.NET4/DevExtreme.AspNet.Data.Tests.NET4.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
<Reference Include="System" />
5656
<Reference Include="System.ComponentModel.DataAnnotations" />
5757
<Reference Include="System.Core" />
58+
<Reference Include="System.Linq.Dynamic.Core, Version=1.0.10.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL">
59+
<HintPath>..\packages\System.Linq.Dynamic.Core.1.0.10\lib\net46\System.Linq.Dynamic.Core.dll</HintPath>
60+
</Reference>
5861
<Reference Include="System.Web.Extensions" />
5962
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
6063
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>

net/DevExtreme.AspNet.Data.Tests.NET4/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net461" />
4+
<package id="System.Linq.Dynamic.Core" version="1.0.10" targetFramework="net461" />
45
<package id="xunit" version="2.3.1" targetFramework="net461" />
56
<package id="xunit.abstractions" version="2.0.1" targetFramework="net461" />
67
<package id="xunit.analyzers" version="0.8.0" targetFramework="net461" />

net/DevExtreme.AspNet.Data.Tests/DevExtreme.AspNet.Data.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<ProjectReference Include="..\DevExtreme.AspNet.Data\DevExtreme.AspNet.Data.csproj" />
99
<ProjectReference Include="..\DevExtreme.AspNet.Data.Tests.Common\DevExtreme.AspNet.Data.Tests.Common.csproj" />
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
11+
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.10" />
1112
<PackageReference Include="xunit" Version="2.3.1" />
1213
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
1314
</ItemGroup>

net/DevExtreme.AspNet.Data.Tests/DynamicBindingTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,16 @@ void Case(IList clientFilter, string expectedExpr, object trueTestValue) {
235235
"a"
236236
);
237237
}
238+
239+
[Fact]
240+
public void T714342() {
241+
var data = System.Linq.Dynamic.Core.DynamicQueryableExtensions.Select(
242+
new[] { new { CategoryID = 1 } }.AsQueryable(),
243+
"new { CategoryID }"
244+
);
245+
246+
Assert.False(DynamicBindingHelper.ShouldUseDynamicBinding(data.ElementType));
247+
}
238248
}
239249

240250
}

net/DevExtreme.AspNet.Data/DynamicBindingHelper.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@ static class DynamicBindingHelper {
1414
static IEnumerable<CSharpArgumentInfo> EMPTY_ARGUMENT_INFO;
1515

1616
public static bool ShouldUseDynamicBinding(Type type) {
17-
return type == typeof(object) || typeof(IDynamicMetaObjectProvider).IsAssignableFrom(type);
17+
if(type == typeof(object))
18+
return true;
19+
20+
if(typeof(IDynamicMetaObjectProvider).IsAssignableFrom(type)) {
21+
var name = type.AssemblyQualifiedName;
22+
if(name.Contains("f__AnonymousType") && name.Contains("System.Linq.Dynamic.Core.DynamicClasses"))
23+
return false;
24+
25+
return true;
26+
}
27+
28+
return false;
1829
}
1930

2031
public static Expression CompileGetMember(Expression target, string clientExpr) {

0 commit comments

Comments
 (0)