Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 2efc6a9

Browse files
authored
Merge pull request #220 from linq2db/version2
Release 2.5.0
2 parents 0c89973 + ff21fd5 commit 2efc6a9

File tree

7 files changed

+54
-16
lines changed

7 files changed

+54
-16
lines changed

Build/linq2db.Default.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>2.4.0</Version>
3+
<Version>2.5.0</Version>
44

55
<Authors>Svyatoslav Danyliv, Igor Tkachev, Dmitry Lukashenko, Ilya Chudin</Authors>
66
<Product>Linq to DB</Product>

Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<PackageVersion Include="NUnit" Version="3.13.2" />
66
<PackageVersion Include="FluentAssertions" Version="5.10.3" />
77

8-
<PackageVersion Include="linq2db" Version="3.5.2" />
9-
<PackageVersion Include="linq2db.Tools" Version="3.5.2" />
8+
<PackageVersion Include="linq2db" Version="3.7.0" />
9+
<PackageVersion Include="linq2db.Tools" Version="3.7.0" />
1010

1111
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
12-
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
12+
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
1313
<PackageVersion Include="System.Interactive.Async" Version="3.2.0"/>
1414

1515
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.6" />

NuGet/linq2db.EntityFrameworkCore.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<dependencies>
1717
<group targetFramework=".NETStandard2.0">
1818
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="2.2.6" />
19-
<dependency id="linq2db" version="3.5.2" />
19+
<dependency id="linq2db" version="3.7.0" />
2020
</group>
2121
</dependencies>
2222
</metadata>

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -780,12 +780,24 @@ public virtual Expression TransformExpression(Expression expression, IDataContex
780780
var tracking = true;
781781
var ignoreTracking = false;
782782

783+
var nonEvaluatableParameters = new HashSet<ParameterExpression>();
784+
783785
TransformInfo LocalTransform(Expression e)
784786
{
785787
e = CompactExpression(e);
786788

787789
switch (e.NodeType)
788790
{
791+
case ExpressionType.Lambda:
792+
{
793+
foreach (var parameter in ((LambdaExpression)e).Parameters)
794+
{
795+
nonEvaluatableParameters.Add(parameter);
796+
}
797+
798+
break;
799+
}
800+
789801
case ExpressionType.Constant:
790802
{
791803
if (dc != null && typeof(EntityQueryable<>).IsSameOrParentOf(e.Type) || typeof(DbSet<>).IsSameOrParentOf(e.Type))
@@ -939,14 +951,18 @@ TransformInfo LocalTransform(Expression e)
939951

940952
if (typeof(IQueryable<>).IsSameOrParentOf(methodCall.Type))
941953
{
942-
// Invoking function to evaluate EF's Subquery located in function
943-
944-
var obj = EvaluateExpression(methodCall.Object);
945-
var arguments = methodCall.Arguments.Select(EvaluateExpression).ToArray();
946-
if (methodCall.Method.Invoke(obj, arguments) is IQueryable result)
954+
if (null == methodCall.Find(nonEvaluatableParameters,
955+
(c, t) => t.NodeType == ExpressionType.Parameter && c.Contains(t)))
947956
{
948-
if (!ExpressionEqualityComparer.Instance.Equals(methodCall, result.Expression))
949-
return new TransformInfo(result.Expression, false, true);
957+
// Invoking function to evaluate EF's Subquery located in function
958+
959+
var obj = EvaluateExpression(methodCall.Object);
960+
var arguments = methodCall.Arguments.Select(EvaluateExpression).ToArray();
961+
if (methodCall.Method.Invoke(obj, arguments) is IQueryable result)
962+
{
963+
if (!ExpressionEqualityComparer.Instance.Equals(methodCall, result.Expression))
964+
return new TransformInfo(result.Expression, false, true);
965+
}
950966
}
951967
}
952968

Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
2222
entity.ToView("EventsView", "views");
2323
});
2424
*/
25+
26+
modelBuilder.Entity<EntityWithArrays>(entity =>
27+
{
28+
});
2529
}
2630

27-
// public virtual DbSet<Event> Events { get; set; } = null!;
31+
public virtual DbSet<Event> Events { get; set; } = null!;
2832
public virtual DbSet<EntityWithArrays> EntityWithArrays { get; set; } = null!;
2933

3034
}

Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,23 @@ where Sql.Ext.PostgreSQL().Overlaps(m.Guids, guids)
8989
}
9090
*/
9191

92+
[Test]
93+
public void TestUnnest()
94+
{
95+
using var db = CreateNpgSqlEntitiesContext();
96+
using var dc = db.CreateLinqToDbConnection();
97+
98+
var guids = new Guid[] { Guid.Parse("271425b1-ebe8-400d-b71d-a6e47a460ae3"),
99+
Guid.Parse("b75de94e-6d7b-4c70-bfa1-f8639a6a5b35") };
100+
101+
var query =
102+
from m in db.EntityWithArrays.ToLinqToDBTable()
103+
from g in dc.Unnest(m.Guids)
104+
where Sql.Ext.PostgreSQL().Overlaps(m.Guids, guids)
105+
select m;
106+
107+
query.Invoking(q => q.ToArray()).Should().NotThrow();
108+
}
109+
92110
}
93111
}

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
variables:
22
solution: 'linq2db.EFCore.sln'
33
build_configuration: 'Release'
4-
assemblyVersion: 2.4.0
5-
nugetVersion: 2.4.0
4+
assemblyVersion: 2.5.0
5+
nugetVersion: 2.5.0
66
artifact_nugets: 'nugets'
77

88
# build on commits to important branches (master + release branches):
@@ -26,7 +26,7 @@ stages:
2626
jobs:
2727
- job: build_job
2828
pool:
29-
vmImage: 'windows-2019'
29+
vmImage: 'windows-2022'
3030
variables:
3131
packageVersion: $(nugetVersion)
3232
displayName: 'Build'

0 commit comments

Comments
 (0)