public void Setup() { Microsoft.Isam.Esent.Interop.JET_TABLEID tableid; this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.tablename = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Microsoft.Isam.Esent.Interop.Api.JetSetSystemParameter(this.instance, Microsoft.Isam.Esent.Interop.JET_SESID.Nil, Microsoft.Isam.Esent.Interop.JET_param.Recovery, 0, "off"); Microsoft.Isam.Esent.Interop.Api.JetSetSystemParameter(this.instance, Microsoft.Isam.Esent.Interop.JET_SESID.Nil, Microsoft.Isam.Esent.Interop.JET_param.MaxTemporaryTables, 0, null); Microsoft.Isam.Esent.Interop.Api.JetInit(ref this.instance); this.session = new Session(this.instance); Microsoft.Isam.Esent.Interop.Api.JetCreateDatabase(this.session, this.database, String.Empty, out this.dbid, Microsoft.Isam.Esent.Interop.CreateDatabaseGrbit.None); Microsoft.Isam.Esent.Interop.Api.JetBeginTransaction(this.session); Microsoft.Isam.Esent.Interop.Api.JetCreateTable(this.session, this.dbid, this.tablename, 0, 100, out tableid); var columndef = new Microsoft.Isam.Esent.Interop.JET_COLUMNDEF() { coltyp = Microsoft.Isam.Esent.Interop.JET_coltyp.Long }; Microsoft.Isam.Esent.Interop.Api.JetAddColumn(this.session, tableid, "Long", columndef, null, 0, out this.columnid); string indexDef = "+long\0\0"; Microsoft.Isam.Esent.Interop.Api.JetCreateIndex(this.session, tableid, "primary", Microsoft.Isam.Esent.Interop.CreateIndexGrbit.IndexPrimary, indexDef, indexDef.Length, 100); Microsoft.Isam.Esent.Interop.Api.JetCloseTable(this.session, tableid); Microsoft.Isam.Esent.Interop.Api.JetCommitTransaction(this.session, Microsoft.Isam.Esent.Interop.CommitTransactionGrbit.LazyFlush); Microsoft.Isam.Esent.Interop.Api.JetOpenTable(this.session, this.dbid, this.tablename, null, 0, Microsoft.Isam.Esent.Interop.OpenTableGrbit.None, out this.tableid); }
/// <summary> /// Initializes a new instance of the <see cref="JET_INSTANCE_INFO"/> class. /// </summary> /// <param name="instance"> /// The instance. /// </param> /// <param name="instanceName"> /// The name of the instance. /// </param> /// <param name="databases"> /// The databases in the instance. /// </param> internal JET_INSTANCE_INFO(JET_INSTANCE instance, string instanceName, string[] databases) { this.hInstanceId = instance; this.szInstanceName = instanceName; if (null == databases) { this.cDatabases = 0; this.databases = null; } else { this.cDatabases = databases.Length; this.databases = Array.AsReadOnly(databases); } }
/// <summary> /// Initialize the JET_INSTANCE. /// </summary> /// <param name="grbit"> /// Initialization options. /// </param> public void Init(InitGrbit grbit) { this.CheckObjectIsNotDisposed(); JET_INSTANCE instance = this.JetInstance; // Use a constrained region so that the handle is // always set after JetInit2 is called. RuntimeHelpers.PrepareConstrainedRegions(); try { // Remember that a failure in JetInit can zero the handle // and that JetTerm should not be called in that case. Api.JetInit2(ref instance, grbit); } finally { this.SetHandle(instance.Value); } }
/// <summary> /// Initializes a new instance of the Session class. A new /// JET_SESSION is allocated from the given instance. /// </summary> /// <param name="instance">The instance to start the session in.</param> public Session(JET_INSTANCE instance) { Api.JetBeginSession(instance, out this.sesid, null, null); this.ResourceWasAllocated(); }
/// <summary> /// Initializes a new instance of the InstanceParameters class. /// </summary> /// <param name="instance">The instance to set parameters on.</param> public InstanceParameters(JET_INSTANCE instance) { this.instance = instance; this.sesid = JET_SESID.Nil; }
/// <summary> /// Initialize a new ESENT session. /// </summary> /// <param name="instance">The initialized instance to create the session in.</param> /// <param name="sesid">Returns the created session.</param> public static void BeginSession(JET_INSTANCE instance, out JET_SESID sesid) { Api.JetBeginSession(instance, out sesid, null, null); }