Skip to content

Commit fd31ab7

Browse files
committed
.Net 10
1 parent 9ebc628 commit fd31ab7

24 files changed

Lines changed: 1144 additions & 109 deletions

src/EntityFrameworkCore.SqlServer.SimpleBulks.DbContextExtensionsTests/Database/ComplexTypes.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ public class ComplexTypeLocation
1717

1818
public double Lng { get; set; }
1919
}
20+
21+
public class JsonComplexTypeAddress
22+
{
23+
public string Street { get; set; }
24+
25+
public ComplexTypeLocation Location { get; set; }
26+
}

src/EntityFrameworkCore.SqlServer.SimpleBulks.DbContextExtensionsTests/Database/OwnedTypes.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ public class OwnedTypeLocation
1717

1818
public double Lng { get; set; }
1919
}
20+
21+
public class JsonOwnedTypeAddress
22+
{
23+
public string Street { get; set; }
24+
25+
public OwnedTypeLocation Location { get; set; }
26+
}

src/EntityFrameworkCore.SqlServer.SimpleBulks.DbContextExtensionsTests/Database/SingleKeyRow.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public class SingleKeyRow<TId>
3939
public ComplexTypeAddress ComplexShippingAddress { get; set; }
4040

4141
public OwnedTypeAddress OwnedShippingAddress { get; set; }
42+
43+
public JsonComplexTypeAddress JsonComplexShippingAddress { get; set; }
44+
45+
public JsonOwnedTypeAddress JsonOwnedShippingAddress { get; set; }
4246
}
4347

4448
public class ExtendedSingleKeyRow<TId> : SingleKeyRow<TId>

src/EntityFrameworkCore.SqlServer.SimpleBulks.DbContextExtensionsTests/Database/TestDbContext.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
3939

4040
modelBuilder.Entity<SingleKeyRow<int>>().Property(x => x.SeasonAsString).HasConversion(v => v.ToString(), v => (Season)Enum.Parse(typeof(Season), v));
4141

42+
modelBuilder.Entity<SingleKeyRow<int>>().ComplexProperty(x => x.JsonComplexShippingAddress, x =>
43+
{
44+
x.ToJson();
45+
});
46+
47+
modelBuilder.Entity<SingleKeyRow<int>>().OwnsOne(x => x.JsonOwnedShippingAddress, x =>
48+
{
49+
x.ToJson();
50+
});
51+
4252
modelBuilder.Entity<CompositeKeyRow<int, int>>().HasKey(x => new { x.Id1, x.Id2 });
4353
modelBuilder.Entity<CompositeKeyRow<int, int>>().Property(x => x.SeasonAsString).HasConversion(v => v.ToString(), v => (Season)Enum.Parse(typeof(Season), v));
4454

src/EntityFrameworkCore.SqlServer.SimpleBulks.DbContextExtensionsTests/DbContextExtensions/BulkDeleteAsyncTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ public BulkDeleteAsyncTests(ITestOutputHelper output, SqlServerFixture fixture)
3535
}
3636
},
3737
OwnedShippingAddress = new OwnedTypeAddress
38+
{
39+
Street = "Street " + i,
40+
Location = new OwnedTypeLocation
41+
{
42+
Lat = 40.7128 + i,
43+
Lng = -74.0060 - i
44+
}
45+
},
46+
JsonComplexShippingAddress = new JsonComplexTypeAddress
47+
{
48+
Street = "Street " + i,
49+
Location = new ComplexTypeLocation
50+
{
51+
Lat = 40.7128 + i,
52+
Lng = -74.0060 - i
53+
}
54+
},
55+
JsonOwnedShippingAddress = new JsonOwnedTypeAddress
3856
{
3957
Street = "Street " + i,
4058
Location = new OwnedTypeLocation

src/EntityFrameworkCore.SqlServer.SimpleBulks.DbContextExtensionsTests/DbContextExtensions/BulkDeleteTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ public BulkDeleteTests(ITestOutputHelper output, SqlServerFixture fixture) : bas
3535
}
3636
},
3737
OwnedShippingAddress = new OwnedTypeAddress
38+
{
39+
Street = "Street " + i,
40+
Location = new OwnedTypeLocation
41+
{
42+
Lat = 40.7128 + i,
43+
Lng = -74.0060 - i
44+
}
45+
},
46+
JsonComplexShippingAddress = new JsonComplexTypeAddress
47+
{
48+
Street = "Street " + i,
49+
Location = new ComplexTypeLocation
50+
{
51+
Lat = 40.7128 + i,
52+
Lng = -74.0060 - i
53+
}
54+
},
55+
JsonOwnedShippingAddress = new JsonOwnedTypeAddress
3856
{
3957
Street = "Street " + i,
4058
Location = new OwnedTypeLocation

src/EntityFrameworkCore.SqlServer.SimpleBulks.DbContextExtensionsTests/DbContextExtensions/BulkInsertAsyncTests.cs

Lines changed: 102 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,24 @@ public async Task BulkInsert_Using_Linq_Without_Transaction(int length)
3939
}
4040
},
4141
OwnedShippingAddress = new OwnedTypeAddress
42+
{
43+
Street = "Street " + i,
44+
Location = new OwnedTypeLocation
45+
{
46+
Lat = 40.7128 + i,
47+
Lng = -74.0060 - i
48+
}
49+
},
50+
JsonComplexShippingAddress = new JsonComplexTypeAddress
51+
{
52+
Street = "Street " + i,
53+
Location = new ComplexTypeLocation
54+
{
55+
Lat = 40.7128 + i,
56+
Lng = -74.0060 - i
57+
}
58+
},
59+
JsonOwnedShippingAddress = new JsonOwnedTypeAddress
4260
{
4361
Street = "Street " + i,
4462
Location = new OwnedTypeLocation
@@ -79,7 +97,9 @@ await _context.BulkInsertAsync(rows,
7997
row.ComplexShippingAddress.Location.Lng,
8098
a = row.OwnedShippingAddress.Street,
8199
b = row.OwnedShippingAddress.Location.Lat,
82-
c = row.OwnedShippingAddress.Location.Lng
100+
c = row.OwnedShippingAddress.Location.Lng,
101+
row.JsonComplexShippingAddress,
102+
row.JsonOwnedShippingAddress
83103
},
84104
options);
85105

@@ -106,6 +126,12 @@ await _context.BulkInsertAsync(compositeKeyRows,
106126
Assert.Equal(rows[i].OwnedShippingAddress?.Street, dbRows[i].OwnedShippingAddress?.Street);
107127
Assert.Equal(rows[i].OwnedShippingAddress?.Location?.Lat, dbRows[i].OwnedShippingAddress?.Location?.Lat);
108128
Assert.Equal(rows[i].OwnedShippingAddress?.Location?.Lng, dbRows[i].OwnedShippingAddress?.Location?.Lng);
129+
Assert.Equal(rows[i].JsonComplexShippingAddress?.Street, dbRows[i].JsonComplexShippingAddress?.Street);
130+
Assert.Equal(rows[i].JsonComplexShippingAddress?.Location?.Lat, dbRows[i].JsonComplexShippingAddress?.Location?.Lat);
131+
Assert.Equal(rows[i].JsonComplexShippingAddress?.Location?.Lng, dbRows[i].JsonComplexShippingAddress?.Location?.Lng);
132+
Assert.Equal(rows[i].JsonOwnedShippingAddress?.Street, dbRows[i].JsonOwnedShippingAddress?.Street);
133+
Assert.Equal(rows[i].JsonOwnedShippingAddress?.Location?.Lat, dbRows[i].JsonOwnedShippingAddress?.Location?.Lat);
134+
Assert.Equal(rows[i].JsonOwnedShippingAddress?.Location?.Lng, dbRows[i].JsonOwnedShippingAddress?.Location?.Lng);
109135

110136
Assert.Equal(compositeKeyRows[i].Id1, dbCompositeKeyRows[i].Id1);
111137
Assert.Equal(compositeKeyRows[i].Id2, dbCompositeKeyRows[i].Id2);
@@ -146,6 +172,24 @@ public async Task BulkInsert_Using_Linq_With_Transaction_Committed(int length)
146172
}
147173
},
148174
OwnedShippingAddress = new OwnedTypeAddress
175+
{
176+
Street = "Street " + i,
177+
Location = new OwnedTypeLocation
178+
{
179+
Lat = 40.7128 + i,
180+
Lng = -74.0060 - i
181+
}
182+
},
183+
JsonComplexShippingAddress = new JsonComplexTypeAddress
184+
{
185+
Street = "Street " + i,
186+
Location = new ComplexTypeLocation
187+
{
188+
Lat = 40.7128 + i,
189+
Lng = -74.0060 - i
190+
}
191+
},
192+
JsonOwnedShippingAddress = new JsonOwnedTypeAddress
149193
{
150194
Street = "Street " + i,
151195
Location = new OwnedTypeLocation
@@ -181,7 +225,9 @@ await _context.BulkInsertAsync(rows,
181225
row.ComplexShippingAddress.Location.Lng,
182226
a = row.OwnedShippingAddress.Street,
183227
b = row.OwnedShippingAddress.Location.Lat,
184-
c = row.OwnedShippingAddress.Location.Lng
228+
c = row.OwnedShippingAddress.Location.Lng,
229+
row.JsonComplexShippingAddress,
230+
row.JsonOwnedShippingAddress
185231
});
186232

187233
await _context.BulkInsertAsync(compositeKeyRows,
@@ -207,6 +253,12 @@ await _context.BulkInsertAsync(compositeKeyRows,
207253
Assert.Equal(rows[i].OwnedShippingAddress?.Street, dbRows[i].OwnedShippingAddress?.Street);
208254
Assert.Equal(rows[i].OwnedShippingAddress?.Location?.Lat, dbRows[i].OwnedShippingAddress?.Location?.Lat);
209255
Assert.Equal(rows[i].OwnedShippingAddress?.Location?.Lng, dbRows[i].OwnedShippingAddress?.Location?.Lng);
256+
Assert.Equal(rows[i].JsonComplexShippingAddress?.Street, dbRows[i].JsonComplexShippingAddress?.Street);
257+
Assert.Equal(rows[i].JsonComplexShippingAddress?.Location?.Lat, dbRows[i].JsonComplexShippingAddress?.Location?.Lat);
258+
Assert.Equal(rows[i].JsonComplexShippingAddress?.Location?.Lng, dbRows[i].JsonComplexShippingAddress?.Location?.Lng);
259+
Assert.Equal(rows[i].JsonOwnedShippingAddress?.Street, dbRows[i].JsonOwnedShippingAddress?.Street);
260+
Assert.Equal(rows[i].JsonOwnedShippingAddress?.Location?.Lat, dbRows[i].JsonOwnedShippingAddress?.Location?.Lat);
261+
Assert.Equal(rows[i].JsonOwnedShippingAddress?.Location?.Lng, dbRows[i].JsonOwnedShippingAddress?.Location?.Lng);
210262

211263
Assert.Equal(compositeKeyRows[i].Id1, dbCompositeKeyRows[i].Id1);
212264
Assert.Equal(compositeKeyRows[i].Id2, dbCompositeKeyRows[i].Id2);
@@ -247,6 +299,24 @@ public async Task BulkInsert_Using_Linq_With_Transaction_RolledBack(int length)
247299
}
248300
},
249301
OwnedShippingAddress = new OwnedTypeAddress
302+
{
303+
Street = "Street " + i,
304+
Location = new OwnedTypeLocation
305+
{
306+
Lat = 40.7128 + i,
307+
Lng = -74.0060 - i
308+
}
309+
},
310+
JsonComplexShippingAddress = new JsonComplexTypeAddress
311+
{
312+
Street = "Street " + i,
313+
Location = new ComplexTypeLocation
314+
{
315+
Lat = 40.7128 + i,
316+
Lng = -74.0060 - i
317+
}
318+
},
319+
JsonOwnedShippingAddress = new JsonOwnedTypeAddress
250320
{
251321
Street = "Street " + i,
252322
Location = new OwnedTypeLocation
@@ -282,7 +352,9 @@ await _context.BulkInsertAsync(rows,
282352
row.ComplexShippingAddress.Location.Lng,
283353
a = row.OwnedShippingAddress.Street,
284354
b = row.OwnedShippingAddress.Location.Lat,
285-
c = row.OwnedShippingAddress.Location.Lng
355+
c = row.OwnedShippingAddress.Location.Lng,
356+
row.JsonComplexShippingAddress,
357+
row.JsonOwnedShippingAddress
286358
});
287359

288360
await _context.BulkInsertAsync(compositeKeyRows,
@@ -404,6 +476,24 @@ public async Task BulkInsert_Using_DynamicString(int length)
404476
}
405477
},
406478
OwnedShippingAddress = new OwnedTypeAddress
479+
{
480+
Street = "Street " + i,
481+
Location = new OwnedTypeLocation
482+
{
483+
Lat = 40.7128 + i,
484+
Lng = -74.0060 - i
485+
}
486+
},
487+
JsonComplexShippingAddress = new JsonComplexTypeAddress
488+
{
489+
Street = "Street " + i,
490+
Location = new ComplexTypeLocation
491+
{
492+
Lat = 40.7128 + i,
493+
Lng = -74.0060 - i
494+
}
495+
},
496+
JsonOwnedShippingAddress = new JsonOwnedTypeAddress
407497
{
408498
Street = "Street " + i,
409499
Location = new OwnedTypeLocation
@@ -443,7 +533,9 @@ await _context.BulkInsertAsync(rows,
443533
"ComplexShippingAddress.Location.Lng",
444534
"OwnedShippingAddress.Street",
445535
"OwnedShippingAddress.Location.Lat",
446-
"OwnedShippingAddress.Location.Lng"
536+
"OwnedShippingAddress.Location.Lng",
537+
"JsonComplexShippingAddress",
538+
"JsonOwnedShippingAddress"
447539
],
448540
options);
449541

@@ -478,6 +570,12 @@ await _context.BulkInsertAsync(compositeKeyRows,
478570
Assert.Equal(rows[i].OwnedShippingAddress?.Street, dbRows[i].OwnedShippingAddress?.Street);
479571
Assert.Equal(rows[i].OwnedShippingAddress?.Location?.Lat, dbRows[i].OwnedShippingAddress?.Location?.Lat);
480572
Assert.Equal(rows[i].OwnedShippingAddress?.Location?.Lng, dbRows[i].OwnedShippingAddress?.Location?.Lng);
573+
Assert.Equal(rows[i].JsonComplexShippingAddress?.Street, dbRows[i].JsonComplexShippingAddress?.Street);
574+
Assert.Equal(rows[i].JsonComplexShippingAddress?.Location?.Lat, dbRows[i].JsonComplexShippingAddress?.Location?.Lat);
575+
Assert.Equal(rows[i].JsonComplexShippingAddress?.Location?.Lng, dbRows[i].JsonComplexShippingAddress?.Location?.Lng);
576+
Assert.Equal(rows[i].JsonOwnedShippingAddress?.Street, dbRows[i].JsonOwnedShippingAddress?.Street);
577+
Assert.Equal(rows[i].JsonOwnedShippingAddress?.Location?.Lat, dbRows[i].JsonOwnedShippingAddress?.Location?.Lat);
578+
Assert.Equal(rows[i].JsonOwnedShippingAddress?.Location?.Lng, dbRows[i].JsonOwnedShippingAddress?.Location?.Lng);
481579

482580
Assert.Equal(compositeKeyRows[i].Id1, dbCompositeKeyRows[i].Id1);
483581
Assert.Equal(compositeKeyRows[i].Id2, dbCompositeKeyRows[i].Id2);

0 commit comments

Comments
 (0)