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

Commit 4ca3158

Browse files
authored
Merge pull request #111 from linq2db/master
Release 5.1.4
2 parents 3ee892e + 2eac9fc commit 4ca3158

File tree

6 files changed

+61
-10
lines changed

6 files changed

+61
-10
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>5.1.3</Version>
3+
<Version>5.1.4</Version>
44

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

Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
157157
.FirstOrDefault(v => CompareProperty(v.p, memberInfo))?.index ?? 0;
158158
}
159159

160+
var isIdentity = prop.GetAnnotations()
161+
.Any(a => a.Name.EndsWith(":ValueGenerationStrategy") && a.Value?.ToString() == "IdentityColumn");
162+
160163
var storeObjectId = GetStoreObjectIdentifier(et);
161164

162165
return new T[]{(T)(Attribute) new ColumnAttribute
@@ -167,7 +170,7 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
167170
DbType = prop.GetColumnType(),
168171
IsPrimaryKey = isPrimaryKey,
169172
PrimaryKeyOrder = primaryKeyOrder,
170-
IsIdentity = prop.ValueGenerated == ValueGenerated.OnAdd,
173+
IsIdentity = isIdentity,
171174
}};
172175
}
173176
}

Source/LinqToDB.EntityFrameworkCore/Internal/LinqToDBForEFQueryProvider.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
using System.Threading.Tasks;
99

1010
using Microsoft.EntityFrameworkCore.Query;
11-
using Microsoft.EntityFrameworkCore.Query.Internal;
12-
13-
using JetBrains.Annotations;
1411
using LinqToDB.Expressions;
1512

1613
namespace LinqToDB.EntityFrameworkCore.Internal
@@ -24,7 +21,7 @@ namespace LinqToDB.EntityFrameworkCore.Internal
2421
/// It may change or be removed without further notice.
2522
/// </summary>
2623
/// <typeparam name="T">Type of query element.</typeparam>
27-
public class LinqToDBForEFQueryProvider<T> : IAsyncQueryProvider, IQueryProviderAsync, IQueryable<T>, System.Collections.Generic.IAsyncEnumerable<T>
24+
public class LinqToDBForEFQueryProvider<T> : IAsyncQueryProvider, IQueryProviderAsync, IQueryable<T>, IAsyncEnumerable<T>
2825
{
2926
/// <summary>
3027
/// Creates instance of adapter.
@@ -84,7 +81,7 @@ public TResult Execute<TResult>(Expression expression)
8481
return QueryProvider.Execute<TResult>(expression);
8582
}
8683

87-
private static MethodInfo _executeAsyncMethodInfo =
84+
private static readonly MethodInfo _executeAsyncMethodInfo =
8885
MemberHelper.MethodOf((IQueryProviderAsync p) => p.ExecuteAsync<int>(null!, default)).GetGenericMethodDefinition();
8986

9087
/// <summary>

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,8 @@ public static bool IsQueryable(MethodCallExpression method, bool enumerable = tr
622622
{
623623
var type = method.Method.DeclaringType;
624624

625-
return type == typeof(Queryable) || (enumerable && type == typeof(Enumerable)) || type == typeof(LinqExtensions) ||
625+
return type == typeof(Queryable) || (enumerable && type == typeof(Enumerable)) || type == typeof(LinqExtensions) ||
626+
type == typeof(DataExtensions) || type == typeof(TableExtensions) ||
626627
type == typeof(EntityFrameworkQueryableExtensions);
627628
}
628629

@@ -881,6 +882,16 @@ TransformInfo LocalTransform(Expression e)
881882
break;
882883
}
883884

885+
if (typeof(ITable<>).IsSameOrParentOf(methodCall.Type))
886+
{
887+
if (generic.Name == "ToLinqToDBTable")
888+
{
889+
return new TransformInfo(methodCall.Arguments[0], false, true);
890+
}
891+
892+
break;
893+
}
894+
884895
if (typeof(IQueryable<>).IsSameOrParentOf(methodCall.Type))
885896
{
886897
// Invoking function to evaluate EF's Subquery located in function

Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ToolsTests.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,46 @@ public void TestNullability([Values(true, false)] bool enableFilter)
773773
}
774774
}
775775

776+
[Test]
777+
public void TestUpdate([Values(true, false)] bool enableFilter)
778+
{
779+
using (var ctx = CreateContext(enableFilter))
780+
{
781+
int? test = 1;
782+
ctx.Employees.IgnoreQueryFilters().Where(e => e.EmployeeId == test).Update(x => new Employee
783+
{
784+
Address = x.Address
785+
786+
});
787+
}
788+
}
789+
790+
[Test]
791+
public async Task TestUpdateAsync([Values(true, false)] bool enableFilter)
792+
{
793+
using (var ctx = CreateContext(enableFilter))
794+
{
795+
int? test = 1;
796+
await ctx.Employees.IgnoreQueryFilters().Where(e => e.EmployeeId == test).UpdateAsync(x => new Employee
797+
{
798+
Address = x.Address
799+
800+
});
801+
}
802+
}
803+
804+
[Test]
805+
public void TestCreateTempTable([Values(true, false)] bool enableFilter)
806+
{
807+
using (var ctx = CreateContext(enableFilter))
808+
{
809+
using var db = ctx.CreateLinqToDbContext();
810+
using var temp = db.CreateTempTable(ctx.Employees, "#TestEmployees");
811+
812+
Assert.AreEqual(ctx.Employees.Count(), temp.Count());
813+
}
814+
}
815+
776816

777817
[Test]
778818
public void TestCommandTimeout()

azure-pipelines.yml

Lines changed: 2 additions & 2 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: 5.1.3
5-
nugetVersion: 5.1.3
4+
assemblyVersion: 5.1.4
5+
nugetVersion: 5.1.4
66
artifact_nugets: 'nugets'
77

88
# build on commits to important branches (master + release branches):

0 commit comments

Comments
 (0)