From 868cc77b903a37c63aaab2eef978ff3297d59ffb Mon Sep 17 00:00:00 2001 From: MaceWindu Date: Sun, 21 Nov 2021 14:13:59 +0100 Subject: [PATCH 1/2] use windows-2022 agent --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e948f6c..08485c2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -26,7 +26,7 @@ stages: jobs: - job: build_job pool: - vmImage: 'windows-2019' + vmImage: 'windows-2022' variables: packageVersion: $(nugetVersion) displayName: 'Build' From 2c64d3edc7372e55cf6f66af2482ddb97e0364c0 Mon Sep 17 00:00:00 2001 From: Svyatoslav Danyliv Date: Fri, 8 Apr 2022 11:00:37 +0300 Subject: [PATCH 2/2] Updated to linq2db 3.7.0. Backported changes from 5.0 --- Build/linq2db.Default.props | 2 +- Directory.Packages.props | 8 ++--- NuGet/linq2db.EntityFrameworkCore.nuspec | 4 +-- .../LinqToDBForEFToolsImplDefault.cs | 30 ++++++++++++++----- .../NpgSqlEntities/NpgSqlEnititesContext.cs | 4 +++ .../NpgSqlTests.cs | 18 +++++++++++ azure-pipelines.yml | 4 +-- 7 files changed, 54 insertions(+), 16 deletions(-) diff --git a/Build/linq2db.Default.props b/Build/linq2db.Default.props index d946dd5..1485967 100644 --- a/Build/linq2db.Default.props +++ b/Build/linq2db.Default.props @@ -1,6 +1,6 @@  - 3.17.0 + 3.18.0 Svyatoslav Danyliv, Igor Tkachev, Dmitry Lukashenko, Ilya Chudin Linq to DB diff --git a/Directory.Packages.props b/Directory.Packages.props index ca07c8b..6686728 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,15 +5,15 @@ - - + + - - + + diff --git a/NuGet/linq2db.EntityFrameworkCore.nuspec b/NuGet/linq2db.EntityFrameworkCore.nuspec index cea960e..e9dff45 100644 --- a/NuGet/linq2db.EntityFrameworkCore.nuspec +++ b/NuGet/linq2db.EntityFrameworkCore.nuspec @@ -15,8 +15,8 @@ MIT-LICENSE.txt - - + + diff --git a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs index 31e704d..9431db7 100644 --- a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs +++ b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs @@ -772,12 +772,24 @@ public virtual Expression TransformExpression(Expression expression, IDataContex var tracking = true; var ignoreTracking = false; + var nonEvaluatableParameters = new HashSet(); + TransformInfo LocalTransform(Expression e) { e = CompactExpression(e); switch (e.NodeType) { + case ExpressionType.Lambda: + { + foreach (var parameter in ((LambdaExpression)e).Parameters) + { + nonEvaluatableParameters.Add(parameter); + } + + break; + } + case ExpressionType.Constant: { if (dc != null && typeof(EntityQueryable<>).IsSameOrParentOf(e.Type) || typeof(DbSet<>).IsSameOrParentOf(e.Type)) @@ -919,14 +931,18 @@ TransformInfo LocalTransform(Expression e) if (typeof(IQueryable<>).IsSameOrParentOf(methodCall.Type)) { - // Invoking function to evaluate EF's Subquery located in function - - var obj = EvaluateExpression(methodCall.Object); - var arguments = methodCall.Arguments.Select(EvaluateExpression).ToArray(); - if (methodCall.Method.Invoke(obj, arguments) is IQueryable result) + if (null == methodCall.Find(nonEvaluatableParameters, + (c, t) => t.NodeType == ExpressionType.Parameter && c.Contains(t))) { - if (!ExpressionEqualityComparer.Instance.Equals(methodCall, result.Expression)) - return new TransformInfo(result.Expression, false, true); + // Invoking function to evaluate EF's Subquery located in function + + var obj = EvaluateExpression(methodCall.Object); + var arguments = methodCall.Arguments.Select(EvaluateExpression).ToArray(); + if (methodCall.Method.Invoke(obj, arguments) is IQueryable result) + { + if (!ExpressionEqualityComparer.Instance.Equals(methodCall, result.Expression)) + return new TransformInfo(result.Expression, false, true); + } } } diff --git a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs index 7a82cec..45e90b9 100644 --- a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs +++ b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs @@ -20,6 +20,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity.HasNoKey(); entity.ToView("EventsView", "views"); }); + + modelBuilder.Entity(entity => + { + }); } public virtual DbSet Events { get; set; } = null!; diff --git a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs index b4d275c..13361a7 100644 --- a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs +++ b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs @@ -87,5 +87,23 @@ where Sql.Ext.PostgreSQL().Overlaps(m.Guids, guids) } } + [Test] + public void TestUnnest() + { + using var db = CreateNpgSqlEntitiesContext(); + using var dc = db.CreateLinqToDbConnection(); + + var guids = new Guid[] { Guid.Parse("271425b1-ebe8-400d-b71d-a6e47a460ae3"), + Guid.Parse("b75de94e-6d7b-4c70-bfa1-f8639a6a5b35") }; + + var query = + from m in db.EntityWithArrays.ToLinqToDBTable() + from g in dc.Unnest(m.Guids) + where Sql.Ext.PostgreSQL().Overlaps(m.Guids, guids) + select m; + + query.Invoking(q => q.ToArray()).Should().NotThrow(); + } + } } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 08485c2..361df91 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,8 +1,8 @@ variables: solution: 'linq2db.EFCore.sln' build_configuration: 'Release' - assemblyVersion: 3.17.0 - nugetVersion: 3.17.0 + assemblyVersion: 3.18.0 + nugetVersion: 3.18.0 artifact_nugets: 'nugets' # build on commits to important branches (master + release branches):