コード例 #1
0
ファイル: Table.cs プロジェクト: stgwilli/ravendb
 /// <summary>
 /// Initializes a new instance of the Table class. The table is
 /// opened from the given database.
 /// </summary>
 /// <param name="sesid">The session to use.</param>
 /// <param name="dbid">The database to open the table in.</param>
 /// <param name="name">The name of the table.</param>
 /// <param name="grbit">JetOpenTable options.</param>
 public Table(JET_SESID sesid, JET_DBID dbid, string name, OpenTableGrbit grbit)
 {
     this.sesid = sesid;
     this.name  = name;
     Api.JetOpenTable(this.sesid, dbid, this.name, null, 0, grbit, out this.tableid);
     this.ResourceWasAllocated();
 }
コード例 #2
0
ファイル: Table.cs プロジェクト: j2jensen/ravendb
 /// <summary>
 /// Initializes a new instance of the Table class. The table is
 /// opened from the given database.
 /// </summary>
 /// <param name="sesid">The session to use.</param>
 /// <param name="dbid">The database to open the table in.</param>
 /// <param name="name">The name of the table.</param>
 /// <param name="grbit">JetOpenTable options.</param>
 public Table(JET_SESID sesid, JET_DBID dbid, string name, OpenTableGrbit grbit)
 {
     this.sesid = sesid;
     this.name = name;
     Api.JetOpenTable(this.sesid, dbid, this.name, null, 0, grbit, out this.tableid);
     this.ResourceWasAllocated();
 }
コード例 #3
0
 /// <summary>
 /// Opens a cursor on a previously created table.
 /// </summary>
 /// <param name="sesid">The database session to use.</param>
 /// <param name="dbid">The database to open the table in.</param>
 /// <param name="tablename">The name of the table to open.</param>
 /// <param name="grbit">Table open options.</param>
 /// <param name="tableid">Returns the opened table.</param>
 /// <returns>An ESENT warning.</returns>
 public static JET_wrn OpenTable(
     JET_SESID sesid,
     JET_DBID dbid,
     string tablename,
     OpenTableGrbit grbit,
     out JET_TABLEID tableid)
 {
     return(Api.JetOpenTable(sesid, dbid, tablename, null, 0, grbit, out tableid));
 }
コード例 #4
0
        /// <summary>
        /// Opens a cursor over the specified table.
        /// </summary>
        /// <param name="tableName">the name of the table to be opened</param>
        /// <param name="exclusive">when true, the table will be opened for exclusive access</param>
        /// <returns>a cursor over the specified table in this database</returns>
        public Cursor OpenCursor(string tableName, bool exclusive)
        {
            lock (this.IsamSession)
            {
                this.CheckDisposed();

                OpenTableGrbit grbit = exclusive ? OpenTableGrbit.DenyRead : OpenTableGrbit.None;
                return(new Cursor(this.IsamSession, this, tableName, grbit));
            }
        }
コード例 #5
0
        public MediaFilesTable(Session session, JET_DBID dbid, string tableName, OpenTableGrbit grbit)
        {
            Session = session;
            JET_TABLEID tableid;

            Api.OpenTable(session, dbid, tableName, grbit, out tableid);
            Table      = tableid;
            _columnDic = null;
            Columns    = new DefaultView(this);
        }
コード例 #6
0
        /// <summary>
        /// Creates a single column with the specified definition in the table
        /// underlying this table definition
        /// </summary>
        /// <param name="columnDefinition">The column definition.</param>
        /// <returns>The <see cref="Columnid"/> object corresponding to the
        /// newly-added column.</returns>
        /// <remarks>
        /// It is currently not possible to add an AutoIncrement column to a
        /// table that is being used by a Cursor.  All such Cursors must be
        /// disposed before the column can be successfully added.
        /// </remarks>
        public Columnid AddColumn(ColumnDefinition columnDefinition)
        {
            lock (this.database.IsamSession)
            {
                using (IsamTransaction trx = new IsamTransaction(this.database.IsamSession))
                {
                    OpenTableGrbit grbit = OpenTableGrbit.None;

                    // if we are trying to add an auto-inc column then we must
                    // be able to open the table for exclusive access.  if we can't
                    // then we will not be able to add the column
                    if ((columnDefinition.Flags & ColumnFlags.AutoIncrement) != 0)
                    {
                        grbit = grbit | OpenTableGrbit.DenyRead;
                    }

                    // open the table with the appropriate access
                    JET_TABLEID tableid;
                    Api.JetOpenTable(this.database.IsamSession.Sesid, this.database.Dbid, this.name, null, 0, grbit, out tableid);

                    // add the new column to the table
                    JET_COLUMNDEF columndef = new JET_COLUMNDEF();
                    columndef.coltyp = DatabaseCommon.ColtypFromColumnDefinition(columnDefinition);
                    columndef.cp     = JET_CP.Unicode;
                    columndef.cbMax  = columnDefinition.MaxLength;
                    columndef.grbit  = Converter.ColumndefGrbitFromColumnFlags(columnDefinition.Flags);
                    byte[] defaultValueBytes = Converter.BytesFromObject(
                        columndef.coltyp,
                        false /* ASCII */,
                        columnDefinition.DefaultValue);
                    int          defaultValueBytesLength = (defaultValueBytes == null) ? 0 : defaultValueBytes.Length;
                    JET_COLUMNID jetColumnid;
                    Api.JetAddColumn(
                        this.database.IsamSession.Sesid,
                        tableid,
                        columnDefinition.Name,
                        columndef,
                        defaultValueBytes,
                        defaultValueBytesLength,
                        out jetColumnid);

                    // commit our change
                    Api.JetCloseTable(this.database.IsamSession.Sesid, tableid);
                    trx.Commit();
                    DatabaseCommon.SchemaUpdateID++;

                    // return the columnid for the new column
                    return(new Columnid(
                               columnDefinition.Name,
                               jetColumnid,
                               columndef.coltyp,
                               columndef.cp == JET_CP.ASCII));
                }
            }
        }
コード例 #7
0
			public Table GetTable(string tableName, OpenTableGrbit options)
			{
				base.CheckObjectIsNotDisposed();
				var table = new Table(this._SessionId, this._DatabaseId, tableName, options);

				lock (this._TableSchema)
				{
					if (!this._TableSchema.ContainsKey(tableName))
					{
						this._TableSchema.Add(tableName, Api.GetColumnDictionary(this._SessionId, table));
					}
				}

				return table;
			}
コード例 #8
0
        /// <summary>Duplicate the cursor, and take the ownership of the copy.</summary>
        /// <remarks><b>NB:</b> this can only be done for a non-table owning cursor.</remarks>
        protected void Duplicate()
        {
            Debug.Assert(!m_bOwnsTable);
            JET_TABLEID idNewTable = JET_TABLEID.Nil;

#if NETFX_CORE
            // JetDupCursor is unavailable on WinRT
            OpenTableGrbit flags = (bReadOnly) ? OpenTableGrbit.ReadOnly : OpenTableGrbit.None;
            Api.JetOpenTable(idSession, m_session.idDatabase, m_serializer.tableName, null, 0, flags, out idNewTable);
#else
            Api.JetDupCursor(idSession, idTable, out idNewTable, DupCursorGrbit.None);
#endif
            m_idTable    = idNewTable;
            m_bOwnsTable = true;
        }
コード例 #9
0
            public Table GetTable(string tableName, OpenTableGrbit options)
            {
                base.CheckObjectIsNotDisposed();
                var table = new Table(this._SessionId, this._DatabaseId, tableName, options);

                lock (this._TableSchema)
                {
                    if (!this._TableSchema.ContainsKey(tableName))
                    {
                        this._TableSchema.Add(tableName, Api.GetColumnDictionary(this._SessionId, table));
                    }
                }

                return(table);
            }
コード例 #10
0
ファイル: MetaDataHelpers.cs プロジェクト: Rationalle/ravendb
        /// <summary>
        /// Try to open a table.
        /// </summary>
        /// <param name="sesid">The session to use.</param>
        /// <param name="dbid">The database to look for the table in.</param>
        /// <param name="tablename">The name of the table.</param>
        /// <param name="grbit">Table open options.</param>
        /// <param name="tableid">Returns the opened tableid.</param>
        /// <returns>True if the table was opened, false if the table doesn't exist.</returns>
        public static bool TryOpenTable(
            JET_SESID sesid,
            JET_DBID dbid,
            string tablename,
            OpenTableGrbit grbit,
            out JET_TABLEID tableid)
        {
            var err = (JET_err)Impl.JetOpenTable(sesid, dbid, tablename, null, 0, grbit, out tableid);
            if (JET_err.ObjectNotFound == err)
            {
                return false;
            }

            Api.Check((int)err);
            Debug.Assert(err >= JET_err.Success, "Exception should have been thrown in case of error");
            return true;
        }
コード例 #11
0
        /// <summary>
        /// Try to open a table.
        /// </summary>
        /// <param name="sesid">The session to use.</param>
        /// <param name="dbid">The database to look for the table in.</param>
        /// <param name="tablename">The name of the table.</param>
        /// <param name="grbit">Table open options.</param>
        /// <param name="tableid">Returns the opened tableid.</param>
        /// <returns>True if the table was opened, false if the table doesn't exist.</returns>
        public static bool TryOpenTable(
            JET_SESID sesid,
            JET_DBID dbid,
            string tablename,
            OpenTableGrbit grbit,
            out JET_TABLEID tableid)
        {
            var err = (JET_err)Impl.JetOpenTable(sesid, dbid, tablename, null, 0, grbit, out tableid);

            if (JET_err.ObjectNotFound == err)
            {
                return(false);
            }

            Api.Check((int)err);
            Debug.Assert(err >= JET_err.Success, "Exception should have been thrown in case of error");
            return(true);
        }
コード例 #12
0
        public bool addType(TypeSerializer ts, bool bOpenAsReadonly)
        {
            Type   t = ts.recordType;
            sTable tmp;

            if (m_tables.TryGetValue(t, out tmp))
            {
                return(false);
            }
            // throw new SerializationException( " The table for type '" + t.Name + "' is already opened." );

            ts.VerifyTableSchema(m_idSession, m_idDatabase);

            OpenTableGrbit flags = (bOpenAsReadonly) ? OpenTableGrbit.ReadOnly : OpenTableGrbit.None;
            JET_TABLEID    idTable;

            Api.JetOpenTable(m_idSession, m_idDatabase, ts.tableName, null, 0, flags, out idTable);

            m_tables[t] = new sTable(idTable, bOpenAsReadonly, ts);

            return(true);
        }
コード例 #13
0
        /// <summary>
        /// Найти таблицу.
        /// </summary>
        /// <param name="session">Сессия.</param>
        /// <param name="database">База данных.</param>
        /// <param name="tableName">Имя таблицы.</param>
        /// <param name="grbit">Флаги.</param>
        /// <returns>Идентификатор таблицы или NULL.</returns>
        protected JET_TABLEID?FindTable(Session session, JET_DBID database, string tableName, OpenTableGrbit grbit = OpenTableGrbit.None)
        {
            JET_TABLEID tableid;

            Api.TryOpenTable(session, database, tableName, grbit, out tableid);
            return(tableid);
        }
コード例 #14
0
ファイル: MetaDataHelpers.cs プロジェクト: subTee/DSInternals
 /// <summary>
 /// Opens a cursor on a previously created table.
 /// </summary>
 /// <param name="sesid">The database session to use.</param>
 /// <param name="dbid">The database to open the table in.</param>
 /// <param name="tablename">The name of the table to open.</param>
 /// <param name="grbit">Table open options.</param>
 /// <param name="tableid">Returns the opened table.</param>
 /// <returns>An ESENT warning.</returns>
 public static JET_wrn OpenTable(
     JET_SESID sesid,
     JET_DBID dbid,
     string tablename,
     OpenTableGrbit grbit,
     out JET_TABLEID tableid)
 {
     return Api.JetOpenTable(sesid, dbid, tablename, null, 0, grbit, out tableid);
 }
コード例 #15
0
ファイル: Api.cs プロジェクト: 925coder/ravendb
 /// <summary>
 /// Opens a cursor on a previously created table.
 /// </summary>
 /// <param name="sesid">The database session to use.</param>
 /// <param name="dbid">The database to open the table in.</param>
 /// <param name="tablename">The name of the table to open.</param>
 /// <param name="parameters">The parameter is not used.</param>
 /// <param name="parametersSize">The parameter is not used.</param>
 /// <param name="grbit">Table open options.</param>
 /// <param name="tableid">Returns the opened table.</param>
 public static void JetOpenTable(JET_SESID sesid, JET_DBID dbid, string tablename, byte[] parameters, int parametersSize, OpenTableGrbit grbit, out JET_TABLEID tableid)
 {
     Api.Check(Impl.JetOpenTable(sesid, dbid, tablename, parameters, parametersSize, grbit, out tableid));
 }
コード例 #16
0
        private ReferencesTable OpenReferencesTable(IEsentSession session, OpenTableGrbit grbit)
        {
            var r = session.OpenTable(ReferencesTableName, grbit);

            return(new ReferencesTable(r.Session, r.Table));
        }
コード例 #17
0
 public void Open(OpenTableGrbit mode)
 {
     _jetCursor = new Table(_jetSession, _jetDatabaseId, ifcHeaderTableName, mode);
     InitColumns();
 }
コード例 #18
0
        private PostsTable OpenPostsTable(IEsentSession session, OpenTableGrbit grbit)
        {
            var r = session.OpenTable(TableName, grbit);

            return(new PostsTable(r.Session, r.Table));
        }
コード例 #19
0
 public void Open(OpenTableGrbit mode)
 {
     _jetCursor = new Table(_jetSession, _jetDatabaseId, ifcHeaderTableName, mode);
     InitColumns();
 }
コード例 #20
0
 public IEsentTable OpenTable(string name, OpenTableGrbit grbit)
 {
     return new EsentTable(this, new Table(JetSesid, Session.JetDbid, name, grbit));
 }
コード例 #21
0
ファイル: Cursor.cs プロジェクト: subTee/DSInternals
        /// <summary>
        /// Initializes a new instance of the <see cref="Cursor"/> class.
        /// </summary>
        /// <param name="isamSession">The session.</param>
        /// <param name="database">The database.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="grbit">The grbit.</param>
        internal Cursor(IsamSession isamSession, IsamDatabase database, string tableName, OpenTableGrbit grbit)
        {
            lock (isamSession)
            {
                this.isamSession = isamSession;
                this.database = database;
                this.tableName = tableName;
                Api.JetOpenTable(isamSession.Sesid, database.Dbid, tableName, null, 0, grbit, out this.tableid);
                this.cleanup = true;
                this.record = new ColumnAccessor(this, isamSession, this.tableid, RetrieveColumnGrbit.None);
                this.editRecord = new ColumnAccessor(this, isamSession, this.tableid, RetrieveColumnGrbit.RetrieveCopy);
                this.indexRecord = new ColumnAccessor(this, isamSession, this.tableid, RetrieveColumnGrbit.RetrieveFromIndex);

                this.MoveBeforeFirst();
            }
        }
コード例 #22
0
        protected BoardReferenceTable OpenTable(IEsentSession session, OpenTableGrbit grbit)
        {
            var table = session.OpenTable(TableName, grbit);

            return(new BoardReferenceTable(table.Session, table));
        }
コード例 #23
0
        private AccessLogTable OpenAccessLogTable(IEsentSession session, OpenTableGrbit grbit)
        {
            var r = session.OpenTable(AccessLogTableName, grbit);

            return(new AccessLogTable(r.Session, r.Table));
        }
コード例 #24
0
 /// <summary>
 /// Constructs and opens a header table
 /// </summary>
 /// <param name="jetSession"></param>
 /// <param name="jetDatabaseId"></param>
 /// <param name="mode"></param>
 public XbimHeaderTable(Session jetSession, JET_DBID jetDatabaseId, OpenTableGrbit mode)
 {
     _jetSession = jetSession;
     _jetDatabaseId = jetDatabaseId;
     Open(mode);
 }
コード例 #25
0
        private MediaFilesTable OpenMediaFilesTable(IEsentSession session, OpenTableGrbit grbit)
        {
            var r = session.OpenTable(MediaFilesTableName, grbit);

            return(new MediaFilesTable(r.Session, r.Table));
        }
コード例 #26
0
 /// <summary>
 /// Constructs and opens a header table
 /// </summary>
 /// <param name="jetSession"></param>
 /// <param name="jetDatabaseId"></param>
 /// <param name="mode"></param>
 public XbimHeaderTable(Session jetSession, JET_DBID jetDatabaseId, OpenTableGrbit mode)
 {
     _jetSession    = jetSession;
     _jetDatabaseId = jetDatabaseId;
     Open(mode);
 }
コード例 #27
0
        private BlobsTable OpenBlobsTable(IEsentSession session, OpenTableGrbit grbit)
        {
            var r = session.OpenTable(BlobsTableName, grbit);

            return(new BlobsTable(r.Session, r.Table));
        }