30 throw new InvalidOperationException(String.Format(
"Database '{0}' is not open.", database.
Name));
32 return database.CreateSafeTransaction(isolation);
49 throw new ArgumentNullException(
"user");
55 var transaction = database.CreateTransaction(isolation);
56 return new Session(transaction, user);
60 var transaction = database.CreateTransaction(isolation);
65 var transaction = database.CreateSafeTransaction(
IsolationLevel.Serializable);
75 return database.CreateUserSession(user,
IsolationLevel.Unspecified);
79 var user = database.Authenticate(userName, password);
81 throw new InvalidOperationException(String.Format(
"Unable to create a session for user '{0}': not authenticated.", userName));
83 return database.CreateUserSession(user);
88 throw new ArgumentException(
"Invalid commit reference specified.");
90 var transaction = database.FindTransactionById(commitId);
91 if (transaction == null)
92 throw new InvalidOperationException(String.Format(
"The request transaction with ID '{0}' is not open.", commitId));
94 return new Session(transaction, user);
103 var user = context.CreateUser(adminName, adminPassword);
108 context.GrantToUserOnSchema(database.
Context.DefaultSchema(), user.
Name,
Privileges.SchemaAll,
true);
115 }
catch (Exception ex) {
122 using (var session = database.CreateSystemSession()) {
125 using (var queryContext = session.CreateQuery()) {
126 return queryContext.Authenticate(username, password);
ITransaction CreateTransaction(IsolationLevel isolation)
Creates a new the transaction with the isolation specified.
static User Authenticate(this IDatabase database, string username, string password)
ITransaction FindById(int commitId)
bool IsOpen
Gets a boolean value that indicates if the database was open.
static void CreateAdminUser(this IDatabase database, IQuery context, string adminName, string adminPassword)
Exception thrown where various problems occur within the database.
static ISession CreateUserSession(this IDatabase database, User user)
static ITransaction FindTransactionById(this IDatabase database, int commidId)
string Name
Gets the name of the database.
static ITransaction CreateTransaction(this IDatabase database, IsolationLevel isolation)
The representation of a single database in the system.
This is a session that is constructed around a given user and a transaction, to the given database...
new IDatabaseContext Context
Gets the context that contains this database.
static ISession CreateInitialSystemSession(this IDatabase database)
An isolated session to a given database for a given user, encapsulating the transaction for operation...
static ISession CreateUserSession(this IDatabase database, User user, IsolationLevel isolation)
static void GrantToPublic(IQuery context)
Provides utilities and properties for handling the SYSTEN schema of a database.
static ISession CreateSystemSession(this IDatabase database, IsolationLevel isolation)
ITransactionFactory TransactionFactory
Gets an object that is used to create new transactions to this database
static ITransaction CreateSafeTransaction(this IDatabase database, IsolationLevel isolation)
static ISession CreateUserSession(this IDatabase database, string userName, string password)
static ISession OpenUserSession(this IDatabase database, int commitId, User user)
const string SecureGroup
THe name of the secure access group.
const string Name
The name of the system schema that contains tables referring to system information.
The simplest implementation of a transaction.
static ISession CreateSystemSession(this IDatabase database)
Provides the information for a user in a database system
TransactionCollection OpenTransactions
Gets the collection of currently open transactions.