Skip to content

Commit ad3fc07

Browse files
committed
Add IMultiRecordPersistDescriptor interface
1 parent 130a23b commit ad3fc07

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

Orm/Xtensive.Orm/Orm/Providers/Interfaces/IPersistDescriptor.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ namespace Xtensive.Orm.Providers
1111
public interface IPersistDescriptor
1212
{
1313
Lazy<PersistRequest> LazyStoreRequest { get; }
14+
Lazy<PersistRequest> ClearRequest { get; }
15+
}
16+
17+
public interface IMultiRecordPersistDescriptor : IPersistDescriptor
18+
{
1419
Lazy<PersistRequest> LazyLevel1BatchStoreRequest { get; }
1520
Lazy<PersistRequest> LazyLevel2BatchStoreRequest { get; }
16-
17-
Lazy<PersistRequest> ClearRequest { get; }
1821
}
19-
}
22+
}

Orm/Xtensive.Orm/Orm/Providers/SqlSessionHandler.IProviderExecutor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ private void Store(IPersistDescriptor descriptor, IEnumerable<Tuple> tuples)
9090
return;
9191
}
9292
var firstTuple = enumerator.Current;
93-
if (firstTuple.Count == 1 && descriptor.LazyLevel1BatchStoreRequest != null && descriptor.LazyLevel2BatchStoreRequest != null) {
93+
if (firstTuple.Count == 1 && descriptor is IMultiRecordPersistDescriptor multiRecordPersistDescriptor) {
9494
var level2Chunk = new List<Tuple>(WellKnown.MultiRowInsertLevel2BatchSize) { firstTuple };
9595
while (enumerator.MoveNext()) {
9696
level2Chunk.Add(enumerator.Current);
9797
if (level2Chunk.Count == WellKnown.MultiRowInsertLevel2BatchSize) {
98-
commandProcessor.RegisterTask(new SqlPersistTask(descriptor.LazyLevel2BatchStoreRequest.Value, level2Chunk));
98+
commandProcessor.RegisterTask(new SqlPersistTask(multiRecordPersistDescriptor.LazyLevel2BatchStoreRequest.Value, level2Chunk));
9999
level2Chunk = new(WellKnown.MultiRowInsertLevel2BatchSize);
100100
}
101101
}
102102
foreach (var level1Chunk in level2Chunk.Chunk(WellKnown.MultiRowInsertLevel1BatchSize)) {
103103
if (level1Chunk.Length == WellKnown.MultiRowInsertLevel1BatchSize) {
104-
commandProcessor.RegisterTask(new SqlPersistTask(descriptor.LazyLevel1BatchStoreRequest.Value, level1Chunk));
104+
commandProcessor.RegisterTask(new SqlPersistTask(multiRecordPersistDescriptor.LazyLevel1BatchStoreRequest.Value, level1Chunk));
105105
}
106106
else {
107107
foreach (var tuple in level1Chunk) {

Orm/Xtensive.Orm/Orm/Providers/TemporaryTables/TemporaryTableDescriptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Xtensive.Orm.Providers
1616
/// <summary>
1717
/// A descriptor of temporary table.
1818
/// </summary>
19-
public sealed class TemporaryTableDescriptor : IPersistDescriptor
19+
public sealed class TemporaryTableDescriptor : IMultiRecordPersistDescriptor
2020
{
2121
/// <summary>
2222
/// Gets the unique name of this temporary table.

Orm/Xtensive.Orm/Orm/Upgrade/Internals/Metadata/MetadataWriter.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ internal sealed class MetadataWriter
2828
private sealed class Descriptor : IPersistDescriptor
2929
{
3030
public Lazy<PersistRequest> LazyStoreRequest { get; set; }
31-
public Lazy<PersistRequest> LazyLevel1BatchStoreRequest { get; }
32-
public Lazy<PersistRequest> LazyLevel2BatchStoreRequest { get; }
3331
public Lazy<PersistRequest> ClearRequest { get; set; }
3432
}
3533

0 commit comments

Comments
 (0)