Skip to content

Commit d853247

Browse files
committed
SessionBound registry improvements
- different error message - method of disabling changes renamed
1 parent 9cf2204 commit d853247

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

Orm/Xtensive.Orm/Orm/Internals/ChangeRegistries/SessionBoundRegistry.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Copyright (C) 2022 Xtensive LLC.
1+
// Copyright (C) 2022-2025 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
4-
// Created by: Dmitri Maximov
4+
// Created by: Alexey Kulakov
55
// Created: 2022.06.14
66

77
using System;
@@ -16,7 +16,7 @@ public abstract class SessionBoundRegistry : SessionBound
1616
{
1717
private bool changesDisabled;
1818

19-
internal Core.Disposable PreventChanges()
19+
internal Core.Disposable DisableRegistrations()
2020
{
2121
changesDisabled = true;
2222
return new Core.Disposable((a) => changesDisabled = false);
@@ -26,7 +26,7 @@ protected void EnsureRegistrationsAllowed()
2626
{
2727
if (changesDisabled) {
2828
throw new InvalidOperationException(
29-
string.Format(Strings.ExSessionXIsActivelyPersistingChangesNoPersistentChangesAllowed, Session.Guid));
29+
string.Format(Strings.ExPersistentChangesAreNotAllowedForThisEvent, Session.Guid));
3030
}
3131
}
3232

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,12 @@ private void ProcessChangesOfEntitySets(Action<EntitySetState> action)
376376
action.Invoke(entitySet);
377377
}
378378

379-
private IDisposable PreventRegistryChanges()
379+
private JoiningDisposable PreventRegistryChanges()
380380
{
381-
return EntityChangeRegistry.PreventChanges()
382-
& EntitySetChangeRegistry.PreventChanges()
383-
& NonPairedReferencesRegistry.PreventChanges()
384-
& ReferenceFieldsChangesRegistry.PreventChanges();
381+
return EntityChangeRegistry.DisableRegistrations()
382+
& EntitySetChangeRegistry.DisableRegistrations()
383+
& NonPairedReferencesRegistry.DisableRegistrations()
384+
& ReferenceFieldsChangesRegistry.DisableRegistrations();
385385
}
386386
}
387387
}

Orm/Xtensive.Orm/Strings.Designer.cs

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Orm/Xtensive.Orm/Strings.resx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -2618,7 +2618,7 @@ Error: {1}</value>
26182618
<data name="LogKeyGeneratorKindForHierarchyWithRootXHasChangedToNone" xml:space="preserve">
26192619
<value>Key generator kind for hierarchy with root '{0}' has changed to None. Make sure that all key values are recieved by constructor and passed to one of Entity constructors.</value>
26202620
</data>
2621-
<data name="ExSessionXIsActivelyPersistingChangesNoPersistentChangesAllowed" xml:space="preserve">
2622-
<value>Session '{0}' is actively persisting changes, persistent objects' changes are not allowed.</value>
2621+
<data name="ExPersistentChangesAreNotAllowedForThisEvent" xml:space="preserve">
2622+
<value>Changes of persistent objects are not allowed for this event due to possibility of changes not reaching database. Try use Session.Events.Persisting or Session.Events.TransactionPreCommitting for such changes for them to be saved correctly.</value>
26232623
</data>
26242624
</root>

0 commit comments

Comments
 (0)