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

Commit 9fc82fd

Browse files
authored
Merge pull request #224 from linq2db/version6
Release 6.7.1
2 parents f8b900a + 9aaa273 commit 9fc82fd

File tree

6 files changed

+51
-4
lines changed

6 files changed

+51
-4
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>6.7.0</Version>
3+
<Version>6.7.1</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: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,17 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
263263
}
264264
}
265265

266+
var behaviour = prop.GetBeforeSaveBehavior();
267+
var skipOnInsert = prop.ValueGenerated.HasFlag(ValueGenerated.OnAdd);
268+
269+
if (skipOnInsert)
270+
{
271+
skipOnInsert = isIdentity || behaviour != PropertySaveBehavior.Save;
272+
}
273+
274+
var skipOnUpdate = behaviour != PropertySaveBehavior.Save ||
275+
prop.ValueGenerated.HasFlag(ValueGenerated.OnUpdate);
276+
266277
return new T[]
267278
{
268279
(T)(Attribute)new ColumnAttribute
@@ -275,7 +286,9 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
275286
IsPrimaryKey = isPrimaryKey,
276287
PrimaryKeyOrder = primaryKeyOrder,
277288
IsIdentity = isIdentity,
278-
IsDiscriminator = discriminator == prop
289+
IsDiscriminator = discriminator == prop,
290+
SkipOnInsert = skipOnInsert,
291+
SkipOnUpdate = skipOnUpdate
279292
}
280293
};
281294
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.ComponentModel.DataAnnotations;
3+
4+
namespace LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.NpgSqlEntities
5+
{
6+
public class EntityWithXmin
7+
{
8+
[Key]
9+
public int Id { get; set; }
10+
11+
public uint xmin { get; set; }
12+
public string Value { get; set; } = null!;
13+
}
14+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
2424
modelBuilder.Entity<EntityWithArrays>(entity =>
2525
{
2626
});
27+
28+
modelBuilder.Entity<EntityWithXmin>(entity =>
29+
{
30+
entity.UseXminAsConcurrencyToken();
31+
});
32+
2733
}
2834

2935
public virtual DbSet<Event> Events { get; set; } = null!;
3036
public virtual DbSet<EntityWithArrays> EntityWithArrays { get; set; } = null!;
37+
public virtual DbSet<EntityWithXmin> EntityWithXmin { get; set; } = null!;
3138

3239
}
3340
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ where Sql.Ext.PostgreSQL().Overlaps(m.Guids, guids)
8787
}
8888
}
8989

90+
[Test]
91+
public void TestConcurrencyToken()
92+
{
93+
using var db = CreateNpgSqlEntitiesContext();
94+
95+
var toInsert = Enumerable.Range(1, 10)
96+
.Select(i => new EntityWithXmin { Value = "Str" + i })
97+
.ToArray();
98+
99+
db.BulkCopy(toInsert);
100+
}
101+
102+
90103
[Test]
91104
public void TestUnnest()
92105
{

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: 6.7.0
5-
nugetVersion: 6.7.0
4+
assemblyVersion: 6.7.1
5+
nugetVersion: 6.7.1
66
artifact_nugets: 'nugets'
77

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

0 commit comments

Comments
 (0)