Skip to content

Commit cd67ce7

Browse files
committed
SessionBoundRegistry changes
- no double change of flag field - explicit init of field value
1 parent baa9eb2 commit cd67ce7

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ namespace Xtensive.Orm.Internals
1414
/// </summary>
1515
public abstract class SessionBoundRegistry : SessionBound
1616
{
17-
private bool changesDisabled;
17+
private bool registrationsDisabled;
1818

1919
internal Core.Disposable DisableRegistrations()
2020
{
21-
changesDisabled = true;
22-
return new Core.Disposable((a) => changesDisabled = false);
21+
if (registrationsDisabled)
22+
return null; // already disabled
23+
registrationsDisabled = true;
24+
return new Core.Disposable((disposing) => registrationsDisabled = false);
2325
}
2426

2527
protected void EnsureRegistrationsAllowed()
@@ -33,6 +35,7 @@ protected void EnsureRegistrationsAllowed()
3335
public SessionBoundRegistry(Session session)
3436
: base(session)
3537
{
38+
registrationsDisabled = false;
3639
}
3740
}
3841
}

Orm/Xtensive.Orm/Strings.Designer.cs

Lines changed: 3 additions & 3 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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="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>
2621+
<data name="ExPersistentChangesAreNotAllowed" xml:space="preserve">
2622+
<value>Changes of persistent objects are not allowed at this point due to possibility of changes not saved to database.</value>
26232623
</data>
26242624
</root>

0 commit comments

Comments
 (0)