-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from linq2db/master
Release 5.3.0
- Loading branch information
Showing
25 changed files
with
401 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
Tests/LinqToDB.EntityFrameworkCore.BaseTests/ForMappingTestsBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using LinqToDB.Data; | ||
using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping; | ||
using NUnit.Framework; | ||
|
||
namespace LinqToDB.EntityFrameworkCore.BaseTests | ||
{ | ||
public abstract class ForMappingTestsBase : TestsBase | ||
{ | ||
public abstract ForMappingContextBase CreateContext(); | ||
|
||
[Test] | ||
public virtual void TestIdentityMapping() | ||
{ | ||
using var context = CreateContext(); | ||
using var connection = context.CreateLinqToDbConnection(); | ||
|
||
var ed = connection.MappingSchema.GetEntityDescriptor(typeof(WithIdentity)); | ||
var pk = ed.Columns.Where(c => c.IsPrimaryKey).Single(); | ||
|
||
pk.IsIdentity.Should().BeTrue(); | ||
} | ||
|
||
[Test] | ||
public virtual void TestNoIdentityMapping() | ||
{ | ||
using var context = CreateContext(); | ||
using var connection = context.CreateLinqToDbConnection(); | ||
|
||
var ed = connection.MappingSchema.GetEntityDescriptor(typeof(NoIdentity)); | ||
var pk = ed.Columns.Where(c => c.IsPrimaryKey).Single(); | ||
|
||
pk.IsIdentity.Should().BeFalse(); | ||
} | ||
|
||
[Test] | ||
public virtual void TestTableCreation() | ||
{ | ||
using var context = CreateContext(); | ||
using var connection = context.CreateLinqToDbConnection(); | ||
|
||
using var t1 = connection.CreateTempTable<WithIdentity>(); | ||
using var t2 = connection.CreateTempTable<NoIdentity>(); | ||
} | ||
|
||
|
||
[Test] | ||
public virtual void TestBulkCopyNoIdentity() | ||
{ | ||
using var context = CreateContext(); | ||
using var connection = context.CreateLinqToDbConnection(); | ||
|
||
using var t = connection.CreateTempTable<NoIdentity>(); | ||
|
||
var items = new List<NoIdentity>() | ||
{ | ||
new() {Id = Guid.NewGuid(), Name = "John Doe"}, | ||
new() {Id = Guid.NewGuid(), Name = "Jane Doe"} | ||
}; | ||
|
||
t.BulkCopy(items); | ||
|
||
|
||
items.Should().BeEquivalentTo(t); | ||
} | ||
|
||
[Test] | ||
public virtual void TestBulkCopyWithIdentity() | ||
{ | ||
using var context = CreateContext(); | ||
using var connection = context.CreateLinqToDbConnection(); | ||
|
||
using var t = connection.CreateTempTable<WithIdentity>(); | ||
|
||
var items = new List<WithIdentity>() | ||
{ | ||
new() {Id = 1, Name = "John Doe"}, | ||
new() {Id = 2, Name = "Jane Doe"} | ||
}; | ||
|
||
t.BulkCopy(items); | ||
|
||
|
||
t.Should().HaveCount(items.Count); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/ForMappingContextBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping | ||
{ | ||
public abstract class ForMappingContextBase : DbContext | ||
{ | ||
protected ForMappingContextBase(DbContextOptions options) : base(options) | ||
{ | ||
} | ||
|
||
public DbSet<WithIdentity> WithIdentity { get; set; } = null!; | ||
public DbSet<NoIdentity> NoIdentity { get; set; } = null!; | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/NoIdentity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping | ||
{ | ||
public class NoIdentity | ||
{ | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } = null!; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/WithIdentity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping | ||
{ | ||
public class WithIdentity | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } = null!; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/ForMappingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using LinqToDB.Data; | ||
using LinqToDB.EntityFrameworkCore.BaseTests; | ||
using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping; | ||
using LinqToDB.EntityFrameworkCore.PomeloMySql.Tests.Models.ForMapping; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace LinqToDB.EntityFrameworkCore.PomeloMySql.Tests | ||
{ | ||
public class ForMappingTests : ForMappingTestsBase | ||
{ | ||
public override ForMappingContextBase CreateContext() | ||
{ | ||
var optionsBuilder = new DbContextOptionsBuilder<ForMappingContext>(); | ||
optionsBuilder.UseMySql("Server=DBHost;Port=3306;Database=TestData;Uid=TestUser;Pwd=TestPassword;charset=utf8;"); | ||
optionsBuilder.UseLoggerFactory(TestUtils.LoggerFactory); | ||
|
||
var options = optionsBuilder.Options; | ||
var ctx = new ForMappingContext(options); | ||
|
||
//ctx.Database.EnsureDeleted(); | ||
ctx.Database.EnsureCreated(); | ||
|
||
return ctx; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/Models/ForMapping/ForMappingContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace LinqToDB.EntityFrameworkCore.PomeloMySql.Tests.Models.ForMapping | ||
{ | ||
public class ForMappingContext : ForMappingContextBase | ||
{ | ||
|
||
public ForMappingContext(DbContextOptions options) : base(options) | ||
{ | ||
|
||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<WithIdentity>(b => | ||
{ | ||
b.HasKey(e => e.Id); | ||
|
||
b.Property(e => e.Id) | ||
.UseMySqlIdentityColumn(); | ||
}); | ||
|
||
modelBuilder.Entity<NoIdentity>(b => | ||
{ | ||
b.HasKey(e => e.Id); | ||
}); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/ForMappingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using LinqToDB.Data; | ||
using LinqToDB.EntityFrameworkCore.BaseTests; | ||
using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping; | ||
using LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.ForMapping; | ||
using Microsoft.EntityFrameworkCore; | ||
using NUnit.Framework; | ||
|
||
namespace LinqToDB.EntityFrameworkCore.PostgreSQL.Tests | ||
{ | ||
[TestFixture] | ||
public class ForMappingTests : ForMappingTestsBase | ||
{ | ||
public override ForMappingContextBase CreateContext() | ||
{ | ||
var optionsBuilder = new DbContextOptionsBuilder<ForMappingContext>(); | ||
optionsBuilder.UseNpgsql("Server=DBHost;Port=5432;Database=ForMapping;User Id=postgres;Password=TestPassword;Pooling=true;MinPoolSize=10;MaxPoolSize=100;"); | ||
optionsBuilder.UseLoggerFactory(TestUtils.LoggerFactory); | ||
|
||
var options = optionsBuilder.Options; | ||
var ctx = new ForMappingContext(options); | ||
|
||
//ctx.Database.EnsureDeleted(); | ||
ctx.Database.EnsureCreated(); | ||
|
||
return ctx; | ||
} | ||
|
||
//Disabled, we cannot create such identity table. | ||
public override void TestBulkCopyWithIdentity() | ||
{ | ||
} | ||
|
||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/ForMapping/ForMappingContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.ForMapping | ||
{ | ||
public class ForMappingContext : ForMappingContextBase | ||
{ | ||
|
||
public ForMappingContext(DbContextOptions options) : base(options) | ||
{ | ||
|
||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<WithIdentity>(b => | ||
{ | ||
b.HasKey(e => e.Id); | ||
|
||
b.Property(e => e.Id) | ||
.UseIdentityAlwaysColumn(); | ||
}); | ||
|
||
modelBuilder.Entity<NoIdentity>(b => | ||
{ | ||
b.HasKey(e => e.Id); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/ForMappingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using LinqToDB.EntityFrameworkCore.BaseTests; | ||
using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping; | ||
using LinqToDB.EntityFrameworkCore.SQLite.Tests.Models.ForMapping; | ||
using Microsoft.EntityFrameworkCore; | ||
using NUnit.Framework; | ||
|
||
namespace LinqToDB.EntityFrameworkCore.SQLite.Tests | ||
{ | ||
[TestFixture] | ||
public class ForMappingTests : ForMappingTestsBase | ||
{ | ||
public override ForMappingContextBase CreateContext() | ||
{ | ||
var optionsBuilder = new DbContextOptionsBuilder<ForMappingContext>(); | ||
optionsBuilder.UseSqlite("DataSource=:memory:"); | ||
optionsBuilder.UseLoggerFactory(TestUtils.LoggerFactory); | ||
|
||
var options = optionsBuilder.Options; | ||
var ctx = new ForMappingContext(options); | ||
|
||
ctx.Database.EnsureCreated(); | ||
|
||
return ctx; | ||
} | ||
} | ||
} |
Oops, something went wrong.