Skip to content

Commit 82f3135

Browse files
Retake/redo some changes reverted in excess
1 parent b169816 commit 82f3135

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

src/NHibernate.Test/Async/Legacy/MultiTableTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public async Task QueriesAsync()
148148
ISession s = OpenSession();
149149
long id = 1L;
150150

151-
if (Dialect is MsSql2000Dialect)
151+
if (TestDialect.HasIdentityNativeGenerator)
152152
{
153153
id = (long) await (s.SaveAsync(new TrivialClass()));
154154
}
@@ -184,7 +184,7 @@ public async Task ConstraintsAsync()
184184
ITransaction t = s.BeginTransaction();
185185
SubMulti sm = new SubMulti();
186186
sm.Amount = 66.5f;
187-
if (Dialect is MsSql2000Dialect)
187+
if (TestDialect.HasIdentityNativeGenerator)
188188
{
189189
await (s.SaveAsync(sm));
190190
}
@@ -215,7 +215,7 @@ public async Task MultiTableAsync()
215215
simp.Name = "simp";
216216
object mid;
217217
object sid;
218-
if (Dialect is MsSql2000Dialect)
218+
if (TestDialect.HasIdentityNativeGenerator)
219219
{
220220
mid = await (s.SaveAsync(multi));
221221
sid = await (s.SaveAsync(simp));
@@ -230,7 +230,7 @@ public async Task MultiTableAsync()
230230
SubMulti sm = new SubMulti();
231231
sm.Amount = 66.5f;
232232
object smid;
233-
if (Dialect is MsSql2000Dialect)
233+
if (TestDialect.HasIdentityNativeGenerator)
234234
{
235235
smid = await (s.SaveAsync(sm));
236236
}
@@ -464,7 +464,7 @@ public async Task MultiTableCollectionsAsync()
464464
simp.Name = "simp";
465465
object mid;
466466
object sid;
467-
if (Dialect is MsSql2000Dialect)
467+
if (TestDialect.HasIdentityNativeGenerator)
468468
{
469469
mid = await (s.SaveAsync(multi));
470470
sid = await (s.SaveAsync(simp));
@@ -484,7 +484,7 @@ public async Task MultiTableCollectionsAsync()
484484
ls.Set = new HashSet<Top> { multi, simp };
485485

486486
object id;
487-
if (Dialect is MsSql2000Dialect)
487+
if (TestDialect.HasIdentityNativeGenerator)
488488
{
489489
id = await (s.SaveAsync(ls));
490490
}
@@ -541,7 +541,7 @@ public async Task MultiTableManyToOneAsync()
541541
simp.Name = "simp";
542542
object mid;
543543

544-
if (Dialect is MsSql2000Dialect)
544+
if (TestDialect.HasIdentityNativeGenerator)
545545
{
546546
mid = await (s.SaveAsync(multi));
547547
}
@@ -556,7 +556,7 @@ public async Task MultiTableManyToOneAsync()
556556
ls.YetAnother = ls;
557557
ls.Name = "Less Simple";
558558
object id;
559-
if (Dialect is MsSql2000Dialect)
559+
if (TestDialect.HasIdentityNativeGenerator)
560560
{
561561
id = await (s.SaveAsync(ls));
562562
}

src/NHibernate.Test/Legacy/MultiTableTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void Queries()
149149
ISession s = OpenSession();
150150
long id = 1L;
151151

152-
if (Dialect is MsSql2000Dialect)
152+
if (TestDialect.HasIdentityNativeGenerator)
153153
{
154154
id = (long) s.Save(new TrivialClass());
155155
}
@@ -185,7 +185,7 @@ public void Constraints()
185185
ITransaction t = s.BeginTransaction();
186186
SubMulti sm = new SubMulti();
187187
sm.Amount = 66.5f;
188-
if (Dialect is MsSql2000Dialect)
188+
if (TestDialect.HasIdentityNativeGenerator)
189189
{
190190
s.Save(sm);
191191
}
@@ -216,7 +216,7 @@ public void MultiTable()
216216
simp.Name = "simp";
217217
object mid;
218218
object sid;
219-
if (Dialect is MsSql2000Dialect)
219+
if (TestDialect.HasIdentityNativeGenerator)
220220
{
221221
mid = s.Save(multi);
222222
sid = s.Save(simp);
@@ -231,7 +231,7 @@ public void MultiTable()
231231
SubMulti sm = new SubMulti();
232232
sm.Amount = 66.5f;
233233
object smid;
234-
if (Dialect is MsSql2000Dialect)
234+
if (TestDialect.HasIdentityNativeGenerator)
235235
{
236236
smid = s.Save(sm);
237237
}
@@ -465,7 +465,7 @@ public void MultiTableCollections()
465465
simp.Name = "simp";
466466
object mid;
467467
object sid;
468-
if (Dialect is MsSql2000Dialect)
468+
if (TestDialect.HasIdentityNativeGenerator)
469469
{
470470
mid = s.Save(multi);
471471
sid = s.Save(simp);
@@ -485,7 +485,7 @@ public void MultiTableCollections()
485485
ls.Set = new HashSet<Top> { multi, simp };
486486

487487
object id;
488-
if (Dialect is MsSql2000Dialect)
488+
if (TestDialect.HasIdentityNativeGenerator)
489489
{
490490
id = s.Save(ls);
491491
}
@@ -542,7 +542,7 @@ public void MultiTableManyToOne()
542542
simp.Name = "simp";
543543
object mid;
544544

545-
if (Dialect is MsSql2000Dialect)
545+
if (TestDialect.HasIdentityNativeGenerator)
546546
{
547547
mid = s.Save(multi);
548548
}
@@ -557,7 +557,7 @@ public void MultiTableManyToOne()
557557
ls.YetAnother = ls;
558558
ls.Name = "Less Simple";
559559
object id;
560-
if (Dialect is MsSql2000Dialect)
560+
if (TestDialect.HasIdentityNativeGenerator)
561561
{
562562
id = s.Save(ls);
563563
}

src/NHibernate.Test/TestDialect.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ public TestDialect(Dialect.Dialect dialect)
2727
_dialect = dialect;
2828
}
2929

30+
/// <summary>
31+
/// Has a native generator strategy resolving to identity.
32+
/// </summary>
33+
public bool HasIdentityNativeGenerator
34+
=> _dialect.NativeIdentifierGeneratorClass == typeof(IdentityGenerator);
35+
3036
public virtual bool SupportsOperatorAll => true;
3137
public virtual bool SupportsOperatorSome => true;
3238
public virtual bool SupportsLocate => true;
@@ -66,7 +72,7 @@ public TestDialect(Dialect.Dialect dialect)
6672
/// <remarks>This property is useful for cases where empty inserts happens only when the entities
6773
/// generator is <c>native</c> while the dialect uses <c>identity</c> for this generator.</remarks>
6874
public bool SupportsEmptyInsertsOrHasNonIdentityNativeGenerator
69-
=> SupportsEmptyInserts || _dialect.NativeIdentifierGeneratorClass != typeof(IdentityGenerator);
75+
=> SupportsEmptyInserts || !HasIdentityNativeGenerator;
7076

7177

7278
/// <summary>

0 commit comments

Comments
 (0)