18 using System.Collections.Generic;
45 if (transaction == null)
46 throw new ArgumentNullException(
"transaction");
49 throw new ArgumentNullException(
"user");
52 throw new ArgumentException(String.Format(
"Cannot open a session for user '{0}'.", user.
Name));
60 StartedOn = DateTimeOffset.UtcNow;
69 GC.SuppressFinalize(
this);
72 public string CurrentSchema {
76 public DateTimeOffset? LastCommandTime {
get;
private set; }
78 public DateTimeOffset StartedOn {
get;
private set; }
93 get {
return GetMetadata(); }
96 private IEnumerable<KeyValuePair<string, object>>
GetMetadata() {
97 return new Dictionary<string, object> {
108 throw new ObjectDisposedException(
"Session");
116 var lockables = objects.OfType<
ILockable>().ToArray();
117 if (lockables.Length == 0)
120 CheckAccess(lockables, accessType);
129 throw new NotImplementedException(
string.Format(
"The locking for isolation '{0}' is not implemented yet.", isolation));
132 if (handle != null) {
133 if (lockHandles == null)
134 lockHandles =
new List<LockHandle>();
136 lockHandles.Add(handle);
144 throw new NotImplementedException(
"The Exit mechanism is not implemented");
149 var lockables = objects.OfType<
ILockable>().ToArray();
150 if (lockables.Length == 0)
155 CheckAccess(lockables, accessType);
159 if (lockHandles == null)
160 lockHandles =
new List<LockHandle>();
162 lockHandles.Add(handle);
167 if (lockHandles == null || lockables == null)
170 foreach (var handle
in lockHandles) {
171 foreach (var lockable
in lockables) {
172 if (handle.IsHandled(lockable))
173 handle.CheckAccess(lockable, accessType);
183 if (lockHandles != null) {
184 foreach (var handle
in lockHandles) {
197 LastCommandTime = DateTimeOffset.UtcNow;
208 DisposeTransaction();
221 DisposeTransaction();
236 return new Query(
this);
244 }
catch (Exception) {
The system implementation of a transaction model that handles isolated operations within a database c...
IDatabase ITransaction. Database
LockingMode
The mode applied to a lock over a resource during a transaction.
void Commit()
Commits all write operation done during the lifetime of this transaction and invalidates it...
void Rollback()
Rolls-back all the modifications made by the user in this session
bool IsSystem
Gets a boolean value indicating if this user represents the SYSTEM special user.
void Exit(IEnumerable< IDbObject > objects, AccessType accessType)
The default implementation of a database in a system.
IDatabase Database
Gets the database this transaction belongs to.
List< LockHandle > lockHandles
The representation of a single database in the system.
bool IsPublic
Gets a boolean value indicating if this user represents the PUBLIC special user.
LockHandle Lock(ILockable[] lockables, AccessType accessType, LockingMode mode)
This is a session that is constructed around a given user and a transaction, to the given database...
IEventSource ParentSource
Gets an optional parent source.
void Rollback()
Rollback any write operations done during the lifetime of this transaction and invalidates it...
IEnumerable< KeyValuePair< string, object > > Metadata
Gets the list of metadata associated to the source.
An isolated session to a given database for a given user, encapsulating the transaction for operation...
void Lock(IEnumerable< IDbObject > objects, AccessType accessType, LockingMode mode)
bool Add(ISession session)
void Dispose(bool disposing)
Session(ITransaction transaction, User user)
Constructs the session for the given user and transaction to the given database.
new ITransactionContext Context
IEnumerable< KeyValuePair< string, object > > GetMetadata()
ActiveSessionList Sessions
Gets a list of all the open sessions to the database.
void CheckAccess(ILockable[] lockables, AccessType accessType)
void Remove(ISession session)
void DisposeTransaction()
void Commit()
Commits the latest changes made by the user in the session.
ISessionContext CreateSessionContext()
ActiveSessionList Sessions
The simplest implementation of a transaction.
Provides the information for a user in a database system
void Access(IEnumerable< IDbObject > objects, AccessType accessType)
Represents the origin of system events, providing a mechanism to fill the metadata before dispatching...
string Name
Gets the name that uniquely identify a user within a database system.