# The C# Database Class

Database class provides the wrapper for interfacing with eXtremeDB databases.

### For an overview see page C# Classes

## Class Definition

        public class Database : IDisposable
        {
            /* Public enums */
            public enum TransactionType {…}
            public enum TransactionPriority {…}
            public enum IsolationLevel {…}
            public enum LogType {…}
            public enum IndexType {…}
            public enum CommitPolicy {…}
            public enum TransSchedPolicy {…}
            public enum BackupType {…}

            /* Embeded classes and structures */
            public struct RuntimeInfo {…}
            public struct BackupInfo {…}
            public struct HAChannelInfo {…}
            public struct ClusterNodeParams {…}
            public struct ClusterWindow {…}
            public struct ClusterNodeInfo {…}
            public class ClusterTCPParams {…}
            public class ClusterMPIParams {…}
            public class ClusterParams {…}
            public struct ClusterInfo {…}
            public class Parameters {…}
            public class SSLParameters {…}
            public abstract class Device {…}
            public class PrivateMemoryDevice {…}
            public class SharedMemoryDevice {…}
            public class FileDevice {…}
            public class MultiFileDevice {…}
            public class RaidDevice {…}
            public class StructDescriptor {…}
            public class EventDescriptor {…}
            public class ClassDescriptor {…}
            public class FieldDescriptor {…}
            public class KeyDescriptor {…}
            public class IndexDescriptor {…}

            /* Constructors */
            public Database()
            public Database(Mode mode)
            public Database(Mode mode, string runtime_path)
            public Database(IDatabaseWrapper impl)
            public Database(IDatabaseWrapper impl, Mode mode)

            /* methods */
            public void Open(String name, Database.Parameters parameters, Database.Device[] devices)
            public void Open(String name, Database.Parameters parameters)
            public void Open(String name, Database.Parameters parameters, long size)
            public void Close()
            public void Dispose()

            public void Extend(Database.Device device)
            public void Extend(Database.Device device, byte[] context)
            public bool Detach(Device device)
            public bool Detach(Device device, byte[] context)

            public Connection Connect()
            public Connection Connect(byte[] context)

            public SqlLocalConnection ConnectSql()
            public SqlRemoteConnection ConnectRemoteSql(string host, int port, int maxAttempts)
            public SqlAggregator ConnectSqlAggregator(SqlLocalConnection[] engines)
            public SqlAggregator ConnectSqlAggregator(SqlLocalConnection[] engines, int bufsize)

            public void setRuntimeOption(int option, int val)
            public int  getRuntimeOption(int option)
            public RuntimeInfo GetRunTimeInfo()

            public void GenerateMcoFile(String path)
            public int GetCurrentTime()

## Public Interface

Enums
Enumerated Database class constants
Constants
Database class constants
Embeded classes and structures
Structures and classes used by the database class

### Constructors

`Database()`
Default constructor. Assumes `Database.Mode` is `Default`.
`Database(Mode mode)`
Constructor that allows the user to specify the database mode.
`Database(Mode mode, string runtime_path)`
Constructor that allows the user to specify both the database mode and the eXtremeDB runtime path.
`Database(IDatabaseWrapper impl)`
Constructor used when `extremedb4net_impl[_debug].dll` is linked via project references.
`Database(IDatabaseWrapper impl, Mode mode)`
Same as the previous constructor, but also allows the user to specify the database mode.

### Methods

`Open(String name, Database.Parameters parameters, Database.Device[] devices)`
Opens a database with the specified name, parameters, and storage devices.
`Open(String name, Database.Parameters parameters)`
Same as the previous method, but without specifying a device array (equivalent to passing `null`).
`Open(String name, Database.Parameters parameters, long size)`
Opens an all-in-memory database.
`Close()`
Closes the database.
`Dispose()`
Equivalent to `Close()`.
`Extend(Database.Device device)`
Extends the database with the specified storage device.
`Extend(Database.Device device, byte[] context)`
Extends the database with the specified device and context data.
`Detach(Device device)`
Detaches the specified device from the database.
`Detach(Device device, byte[] context)`
Detaches the specified device from the database using the provided context.
`Connect()`
Creates a new database connection.
`Connect(byte[] context)`
Creates a new database connection with the specified context.
`ConnectSql()`
Creates a new local SQL database connection.
`ConnectRemoteSql(string host, int port, int maxAttempts)`
Creates a new remote SQL database connection to the specified host and port, with retry logic.
`ConnectSqlAggregator(SqlLocalConnection[] engines)`
Creates a new aggregated SQL connection using the specified engines and a default buffer size of 64 KB.
`ConnectSqlAggregator(SqlLocalConnection[] engines, int bufsize)`
Creates a new aggregated SQL connection using the specified engines and buffer size.
`setRuntimeOption(int option, int val)`
Sets a database runtime option.
`getRuntimeOption(int option)`
Retrieves the current value of a database runtime option.
`GetRunTimeInfo()`
Retrieves information about the current database runtime.
`GenerateMcoFile(String path)`
Generates an eXtremeDB MCO schema file based on .NET class definitions.
`GetCurrentTime()`
Returns the current time in milliseconds.