Skip to content

Commit 85d7c8c

Browse files
committed
EntityLockProviderCache
1 parent eac057d commit 85d7c8c

File tree

6 files changed

+14
-30
lines changed

6 files changed

+14
-30
lines changed

Orm/Xtensive.Orm/Orm/Domain.cs

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ public static Domain Demand()
150150
/// </summary>
151151
internal ConcurrentDictionary<AssociationInfo, (CompilableProvider, Parameter<Xtensive.Tuples.Tuple>)> RefsToEntityQueryCache { get; } = new();
152152

153+
/// <summary>
154+
/// Caches providers that lock certain type of entity with certain <see cref="LockMode"/> and <see cref="LockBehavior"/>.
155+
/// </summary>
156+
internal ConcurrentDictionary<(TypeInfo, LockMode, LockBehavior), ExecutableProvider> EntityLockProviderCache { get; } = new();
157+
153158
internal object UpgradeContextCookie { get; private set; }
154159

155160
internal SqlConnection SingleConnection { get; private set; }

Orm/Xtensive.Orm/Orm/DomainBound.cs

+4-17
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,24 @@
44
// Created by: Dmitri Maximov
55
// Created: 2007.08.10
66

7-
using System;
87
using Xtensive.Core;
98

10-
using Xtensive.IoC;
11-
using Xtensive.Orm;
12-
139
namespace Xtensive.Orm
1410
{
1511
/// <summary>
1612
/// Base class for all objects that are bound to the <see cref="Domain"/> instance.
1713
/// </summary>
1814
public abstract class DomainBound: IContextBound<Domain>
1915
{
20-
private Domain domain;
21-
2216
/// <summary>
2317
/// Gets <see cref="Domain"/> to which current instance is bound.
2418
/// </summary>
25-
public Domain Domain
26-
{
27-
get { return domain; }
28-
internal set { domain = value; }
29-
}
19+
public Domain Domain { get; internal set; }
3020

3121
#region IContextBound<Domain> Members
3222

3323
/// <inheritdoc/>
34-
Domain IContextBound<Domain>.Context
35-
{
36-
get { return domain; }
37-
}
24+
Domain IContextBound<Domain>.Context => Domain;
3825

3926
#endregion
4027

@@ -57,7 +44,7 @@ protected DomainBound()
5744
protected DomainBound(Domain domain)
5845
{
5946
ArgumentNullException.ThrowIfNull(domain);
60-
this.domain = domain;
47+
Domain = domain;
6148
}
6249
}
63-
}
50+
}

Orm/Xtensive.Orm/Orm/Entity.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public void Lock(LockMode lockMode, LockBehavior lockBehavior)
270270
{
271271
var parameterContext = new ParameterContext();
272272
parameterContext.SetValue(keyParameter, Key.Value);
273-
var source = Session.StorageNode.EntityLockProviderCache.GetOrAdd((TypeInfo, lockMode, lockBehavior), ExecutableProviderGenerator, Session);
273+
var source = Session.Domain.EntityLockProviderCache.GetOrAdd((TypeInfo, lockMode, lockBehavior), ExecutableProviderGenerator, Session);
274274
using var recordSetReader = source.GetRecordSetReader(Session, parameterContext);
275275
recordSetReader.MoveNext();
276276
}

Orm/Xtensive.Orm/Orm/Providers/SessionHandler.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public abstract partial class SessionHandler : IDisposable, IAsyncDisposable
2222
/// <summary>
2323
/// Gets <see cref="HandlerAccessor"/>.
2424
/// </summary>
25-
protected HandlerAccessor Handlers { get; private set; }
25+
protected HandlerAccessor Handlers => Session.Handlers;
2626

2727
/// <summary>
2828
/// Gets the current <see cref="Session"/>.
2929
/// </summary>
30-
public Session Session { get; private set; }
30+
public Session Session { get; }
3131

3232
/// <summary>
3333
/// Gets the real session handler (the final handler in chain of all <see cref="ChainingSessionHandler"/>s).
@@ -117,7 +117,6 @@ public virtual void Dispose()
117117
protected SessionHandler(Session session)
118118
{
119119
Session = session;
120-
Handlers = session.Handlers;
121120
}
122121
}
123-
}
122+
}

Orm/Xtensive.Orm/Orm/Session.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public static Func<Session> Resolver
235235

236236
internal SessionHandler Handler { get; set; }
237237

238-
internal HandlerAccessor Handlers { get; private set; }
238+
internal HandlerAccessor Handlers => Domain.Handlers;
239239

240240
internal SyncManager PairSyncManager { get; }
241241

@@ -546,7 +546,6 @@ internal Session(Domain domain, StorageNode selectedStorageNode, SessionConfigur
546546
storageNode = selectedStorageNode;
547547

548548
// Handlers
549-
Handlers = domain.Handlers;
550549
Handler = CreateSessionHandler();
551550

552551
// Caches, registry

Orm/Xtensive.Orm/Orm/StorageNode.cs

-6
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ public sealed class StorageNode : ISessionSource
4444
/// </summary>
4545
public TypeIdRegistry TypeIdRegistry { get; private set; }
4646

47-
/// <summary>
48-
/// Caches providers that lock certain type of entity with certain <see cref="LockMode"/> and <see cref="LockBehavior"/>.
49-
/// </summary>
50-
internal ConcurrentDictionary<(TypeInfo, LockMode, LockBehavior), ExecutableProvider> EntityLockProviderCache { get; } = new();
51-
52-
5347
/// <summary>
5448
/// Caches certain info about EntitySet fields, e.g. queries to fetch current count or items.
5549
/// </summary>

0 commit comments

Comments
 (0)