Skip to content

Commit

Permalink
Merge pull request #219 from linq2db/version3
Browse files Browse the repository at this point in the history
Release 3.18.0
  • Loading branch information
sdanyliv authored Apr 8, 2022
2 parents 08d71c5 + 2c64d3e commit c21b399
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Build/linq2db.Default.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>3.17.0</Version>
<Version>3.18.0</Version>

<Authors>Svyatoslav Danyliv, Igor Tkachev, Dmitry Lukashenko, Ilya Chudin</Authors>
<Product>Linq to DB</Product>
Expand Down
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<PackageVersion Include="NUnit" Version="3.13.2" />
<PackageVersion Include="FluentAssertions" Version="5.10.3" />

<PackageVersion Include="linq2db" Version="3.5.2" />
<PackageVersion Include="linq2db.Tools" Version="3.5.2" />
<PackageVersion Include="linq2db" Version="3.7.0" />
<PackageVersion Include="linq2db.Tools" Version="3.7.0" />

<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />


<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.21" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.21" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.6" />

<PackageVersion Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.EntityFrameworkCore.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<license type="file">MIT-LICENSE.txt</license>
<dependencies>
<group targetFramework=".NETStandard2.0">
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="3.1.21" />
<dependency id="linq2db" version="3.5.2" />
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="3.1.6" />
<dependency id="linq2db" version="3.7.0" />
</group>
</dependencies>
</metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,12 +772,24 @@ public virtual Expression TransformExpression(Expression expression, IDataContex
var tracking = true;
var ignoreTracking = false;

var nonEvaluatableParameters = new HashSet<ParameterExpression>();

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))
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.HasNoKey();
entity.ToView("EventsView", "views");
});

modelBuilder.Entity<EntityWithArrays>(entity =>
{
});
}

public virtual DbSet<Event> Events { get; set; } = null!;
Expand Down
18 changes: 18 additions & 0 deletions Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

}
}
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -26,7 +26,7 @@ stages:
jobs:
- job: build_job
pool:
vmImage: 'windows-2019'
vmImage: 'windows-2022'
variables:
packageVersion: $(nugetVersion)
displayName: 'Build'
Expand Down

0 comments on commit c21b399

Please sign in to comment.