Skip to content

Commit 5aa9ba9

Browse files
authored
Merge pull request #174 from servicetitan/mergeUpstream
Merge upstream
2 parents dda3543 + d0e33df commit 5aa9ba9

File tree

6 files changed

+130
-43
lines changed

6 files changed

+130
-43
lines changed

ChangeLog/7.2.0-Beta-1-dev.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
[main] DomainConfiguration.MaxNumberOfConditions is introduced
77
[main] SqlDml.Truncate() is introduced.
88
[main] WellKnown.MaxNumberOfConditions became obsolete, use new DomainConfiguration.MaxNumberOfConditions if needed
9+
[main] TypeHelper.GetSingleConstructor() and .GetSingleConstructorOrDefault() are marked obsolete
10+
[main] Session.DisableSaveChages() methods return null value in more cases. See methods' summaries
11+
[main] DirectSessionAccessor.OpenSystemLogicOnlyRegion() returns disposable struct instead of IDisposable
12+
[main] OperationRegistry's Disable/EnableSystemOperationRegistration methods return disposable struct instead of IDisposable
913
[main] Temporary tables cleanup now uses TRUNCATE instead of DELETE when possible
1014
[main] Temporary tables population is increased with multi-row inserts - 256 and 16 items per INSERT
1115
[main] PersistParameterBinding has new field RowIndex, use it for multi-row inserts if needed

Orm/Xtensive.Orm/IoC/ServiceContainer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,13 @@ public static IServiceContainer Create(Type containerType, object configuration,
227227
private static ConstructorInvoker FindConstructorInvoker(Type containerType, params Type[] argumentTypes) =>
228228
containerType.GetSingleConstructorInvokerOrDefault(argumentTypes);
229229
#else
230+
#pragma warning disable CS0612 // Type or member is obsolete
230231
private static ConstructorInfo FindConstructor(Type containerType, params Type[] argumentTypes) =>
231232
containerType.GetSingleConstructorOrDefault(argumentTypes);
233+
#pragma warning restore CS0612 // Type or member is obsolete
232234
#endif
233235

234-
#endregion
236+
#endregion
235237

236238
/// <summary>
237239
/// Creates <see cref="IServiceContainer"/> by default configuration.

Orm/Xtensive.Orm/Orm/Operations/OperationRegistry.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public sealed class OperationRegistry
2121
private readonly OperationRegistry registry;
2222
private readonly bool prevIsSystemOperationRegistrationEnabled;
2323

24-
public SystemOperationRegistrationScope(OperationRegistry registry, bool enable)
24+
internal SystemOperationRegistrationScope(OperationRegistry registry, bool enable)
2525
{
2626
this.registry = registry;
2727
prevIsSystemOperationRegistrationEnabled = registry.IsSystemOperationRegistrationEnabled;
@@ -32,9 +32,9 @@ public SystemOperationRegistrationScope(OperationRegistry registry, bool enable)
3232
}
3333

3434
private readonly ICompletableScope blockingScope;
35+
private readonly Collections.Deque<ICompletableScope> scopes = new();
3536
private bool isOperationRegistrationEnabled = true;
3637
private bool isUndoOperationRegistrationEnabled = true;
37-
private Collections.Deque<ICompletableScope> scopes = new Collections.Deque<ICompletableScope>();
3838

3939
/// <summary>
4040
/// Gets the session this instance is bound to.

Orm/Xtensive.Orm/Orm/Session.Persist.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ private async ValueTask Persist(PersistReason reason, bool isAsync, Cancellation
229229
}
230230

231231
/// <summary>
232-
/// Temporarily disables all save changes operations (both explicit ant automatic)
232+
/// Temporarily disables all save changes operations (both explicit ant automatic)
233233
/// for specified <paramref name="target"/>.
234234
/// Such entity is prevented from being persisted to the database,
235235
/// when <see cref="SaveChanges"/> is called or query is executed.
@@ -239,34 +239,37 @@ private async ValueTask Persist(PersistReason reason, bool isAsync, Cancellation
239239
/// all entities that reference <paramref name="target"/> are also pinned automatically.
240240
/// </summary>
241241
/// <param name="target">The entity to disable persisting.</param>
242-
/// <returns>A special object that controls lifetime of such behavior if <paramref name="target"/> was not previously processed by the method,
243-
/// otherwise <see langword="null"/>.</returns>
242+
/// <returns>
243+
/// A special object that controls lifetime of such behavior if <paramref name="target"/> was not previously processed by the method
244+
/// and automatic saving of changes is enabled (<see cref="SessionOptions.AutoSaveChanges"/>),
245+
/// otherwise <see langword="null"/>.
246+
/// </returns>
244247
public IDisposable DisableSaveChanges(IEntity target)
245248
{
246249
EnsureNotDisposed();
247250
ArgumentValidator.EnsureArgumentNotNull(target, "target");
251+
if (!Configuration.Supports(SessionOptions.AutoSaveChanges))
252+
return null; // No need to pin in this case
253+
248254
var targetEntity = (Entity) target;
249255
targetEntity.EnsureNotRemoved();
250-
return Configuration.Supports(SessionOptions.AutoSaveChanges)
251-
? pinner.RegisterRoot(targetEntity.State)
252-
: EmptyDisposable; // No need to pin in this case
256+
return pinner.RegisterRoot(targetEntity.State);
253257
}
254258

255259
/// <summary>
256260
/// Temporarily disables only automatic save changes operations before queries, etc.
257261
/// Explicit call of <see cref="SaveChanges"/> will lead to flush changes anyway.
258262
/// If save changes is to be performed due to starting a nested transaction or committing a transaction,
259263
/// active disabling save changes scope will lead to failure.
260-
/// <returns>A special object that controls lifetime of such behavior if there is no active scope,
264+
/// <returns>A special object that controls lifetime of such behavior if there is no active scope
265+
/// and automatic saving of changes is enabled (<see cref="SessionOptions.AutoSaveChanges"/>),
261266
/// otherwise <see langword="null"/>.</returns>
262267
/// </summary>
263268
public IDisposable DisableSaveChanges()
264269
{
265-
if (!Configuration.Supports(SessionOptions.AutoSaveChanges)) {
266-
return EmptyDisposable; // No need to pin in this case
270+
if (!Configuration.Supports(SessionOptions.AutoSaveChanges) || disableAutoSaveChanges) {
271+
return null; // No need to pin in these cases
267272
}
268-
if (disableAutoSaveChanges)
269-
return null;
270273

271274
disableAutoSaveChanges = true;
272275
return new Disposable(_ => {
@@ -323,7 +326,7 @@ private void CancelEntitiesChanges()
323326
newEntity.Update(null);
324327
newEntity.PersistenceState = PersistenceState.Removed;
325328
}
326-
329+
327330
foreach (var modifiedEntity in EntityChangeRegistry.GetItems(PersistenceState.Modified)) {
328331
modifiedEntity.RollbackDifference();
329332
modifiedEntity.PersistenceState = PersistenceState.Synchronized;

Orm/Xtensive.Orm/Orm/Session.SystemLogic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public partial class Session
1616
private readonly Session session;
1717
private readonly bool prevIsSystemLogicOnly;
1818

19-
public SystemLogicOnlyRegionScope(Session session)
19+
internal SystemLogicOnlyRegionScope(Session session)
2020
{
2121
this.session = session;
2222
prevIsSystemLogicOnly = session.IsSystemLogicOnly;

0 commit comments

Comments
 (0)