public void Setup()
        {
            this.native = new NATIVE_COLUMNBASE
            {
                cbMax            = 1,
                coltyp           = unchecked ((uint)JET_coltyp.Text),
                columnid         = 2,
                cp               = unchecked ((ushort)JET_CP.Unicode),
                grbit            = unchecked ((uint)ColumndefGrbit.ColumnNotNULL),
                szBaseColumnName = "basecolumn",
                szBaseTableName  = "basetable",
            };

            this.nativeWide = new NATIVE_COLUMNBASE_WIDE
            {
                cbMax            = 1,
                coltyp           = unchecked ((uint)JET_coltyp.Text),
                columnid         = 2,
                cp               = unchecked ((ushort)JET_CP.Unicode),
                grbit            = unchecked ((uint)ColumndefGrbit.ColumnNotNULL),
                szBaseColumnName = "basecolumn",
                szBaseTableName  = "basetable",
            };

            this.managed     = new JET_COLUMNBASE(this.native);
            this.managedWide = new JET_COLUMNBASE(this.native);
        }
예제 #2
0
 /// <summary>
 /// Retrieves information about a table column.
 /// </summary>
 /// <param name="sesid">The session to use.</param>
 /// <param name="tableid">The table containing the column.</param>
 /// <param name="columnid">The columnid of the column.</param>
 /// <param name="columnbase">Filled in with information about the column.</param>
 public static void JetGetTableColumnInfo(
     JET_SESID sesid,
     JET_TABLEID tableid,
     JET_COLUMNID columnid,
     out JET_COLUMNBASE columnbase)
 {
     Api.Check(Api.Impl.JetGetTableColumnInfo(sesid, tableid, columnid, out columnbase));
 }
예제 #3
0
        public void JetColumnbaseToString()
        {
            var columndef = new JET_COLUMNBASE {
                coltyp = JET_coltyp.Text, grbit = ColumndefGrbit.ColumnFixed
            };

            Assert.AreEqual("JET_COLUMNBASE(Text,ColumnFixed)", columndef.ToString());
        }
예제 #4
0
 /// <summary>
 /// Retrieves information about a table column.
 /// </summary>
 /// <param name="sesid">The session to use.</param>
 /// <param name="tableid">The table containing the column.</param>
 /// <param name="columnid">The columnid of the column.</param>
 /// <param name="columnbase">Filled in with information about the column.</param>
 public static void JetGetTableColumnInfo(
     JET_SESID sesid,
     JET_TABLEID tableid,
     JET_COLUMNID columnid,
     out JET_COLUMNBASE columnbase)
 {
     Api.Check(Api.Impl.JetGetTableColumnInfo(sesid, tableid, columnid, out columnbase));
 }
예제 #5
0
 /// <summary>
 /// Retrieves information about a column in a table.
 /// </summary>
 /// <param name="sesid">The session to use.</param>
 /// <param name="dbid">The database that contains the table.</param>
 /// <param name="tablename">The name of the table containing the column.</param>
 /// <param name="columnid">The ID of the column.</param>
 /// <param name="columnbase">Filled in with information about the columns in the table.</param>
 public static void JetGetColumnInfo(
     JET_SESID sesid,
     JET_DBID dbid,
     string tablename,
     JET_COLUMNID columnid,
     out JET_COLUMNBASE columnbase)
 {
     Api.Check(Api.Impl.JetGetColumnInfo(sesid, dbid, tablename, columnid, out columnbase));
 }
예제 #6
0
 /// <summary>
 /// Retrieves information about a column in a table.
 /// </summary>
 /// <param name="sesid">The session to use.</param>
 /// <param name="dbid">The database that contains the table.</param>
 /// <param name="tablename">The name of the table containing the column.</param>
 /// <param name="columnid">The ID of the column.</param>
 /// <param name="columnbase">Filled in with information about the columns in the table.</param>
 public static void JetGetColumnInfo(
         JET_SESID sesid,
         JET_DBID dbid,
         string tablename,
         JET_COLUMNID columnid,
         out JET_COLUMNBASE columnbase)
 {
     Api.Check(Api.Impl.JetGetColumnInfo(sesid, dbid, tablename, columnid, out columnbase));
 }
예제 #7
0
        public void Setup()
        {
            this.native = new NATIVE_COLUMNBASE
            {
                cbMax = 1,
                coltyp = unchecked((uint)JET_coltyp.Text),
                columnid = 2,
                cp = unchecked((ushort)JET_CP.Unicode),
                grbit = unchecked((uint)ColumndefGrbit.ColumnNotNULL),
                szBaseColumnName = "basecolumn",
                szBaseTableName = "basetable",
            };

            this.managed = new JET_COLUMNBASE(this.native);
        }
예제 #8
0
        /// <summary>
        /// Creates a <see cref="ColumnDefinition"/> object representing the column passed in by <paramref name="columnBase"/>.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="columnBase">The <see cref="JET_COLUMNBASE"/> object that represents this particular column.</param>
        /// <returns>
        /// A <see cref="ColumnDefinition"/> object based on the <paramref name="columnBase"/> object.
        /// </returns>
        internal static ColumnDefinition Load(IsamDatabase database, string tableName, JET_COLUMNBASE columnBase)
        {
            lock (database.IsamSession)
            {
                using (IsamTransaction trx = new IsamTransaction(database.IsamSession))
                {
                    JET_SESID sesid = database.IsamSession.Sesid;

                    // load info for the column
                    ColumnDefinition columnDefinition = new ColumnDefinition();

                    columnDefinition.columnid = new Columnid(columnBase);
                    columnDefinition.name = columnDefinition.columnid.Name;
                    columnDefinition.type = columnDefinition.columnid.Type;

                    columnDefinition.flags = ColumnFlagsFromGrbits(columnBase.grbit);

                    columnDefinition.maxLength = (int)columnBase.cbMax;
                    columnDefinition.IsAscii = columnBase.cp == JET_CP.ASCII;

                    // there is currently no efficient means to retrieve the
                    // default value of a specific column from JET.  so, we are
                    // going to reach into the catalog and fetch it directly
                    JET_TABLEID tableidCatalog;
                    Api.JetOpenTable(
                        sesid,
                        database.Dbid,
                        "MSysObjects",
                        null,
                        0,
                        OpenTableGrbit.ReadOnly,
                        out tableidCatalog);

                    Api.JetSetCurrentIndex(sesid, tableidCatalog, "RootObjects");
                    Api.MakeKey(sesid, tableidCatalog, true, MakeKeyGrbit.NewKey);
                    Api.MakeKey(
                        sesid,
                        tableidCatalog,
                        Converter.BytesFromObject(JET_coltyp.Text, true, columnBase.szBaseTableName),
                        MakeKeyGrbit.None);
                    Api.JetSeek(sesid, tableidCatalog, SeekGrbit.SeekEQ);
                    JET_COLUMNBASE columnbaseCatalog;
                    Api.JetGetTableColumnInfo(sesid, tableidCatalog, "ObjidTable", out columnbaseCatalog);
                    uint objidTable = Api.RetrieveColumnAsUInt32(sesid, tableidCatalog, columnbaseCatalog.columnid).GetValueOrDefault();

                    Api.JetSetCurrentIndex(sesid, tableidCatalog, "Name");
                    Api.MakeKey(sesid, tableidCatalog, objidTable, MakeKeyGrbit.NewKey);
                    Api.MakeKey(sesid, tableidCatalog, (short)2, MakeKeyGrbit.None);
                    Api.MakeKey(sesid, tableidCatalog, columnBase.szBaseColumnName, Encoding.ASCII, MakeKeyGrbit.None);
                    Api.JetSeek(sesid, tableidCatalog, SeekGrbit.SeekEQ);

                    Api.JetGetTableColumnInfo(sesid, tableidCatalog, "DefaultValue", out columnbaseCatalog);
                    byte[] defaultValueBytes = Api.RetrieveColumn(sesid, tableidCatalog, columnbaseCatalog.columnid);

                    Columnid isamColumnid = columnDefinition.columnid;
                    columnDefinition.defaultValue = Converter.ObjectFromBytes(
                        isamColumnid.Coltyp,
                        columnDefinition.IsAscii,
                        defaultValueBytes);

                    columnDefinition.ReadOnly = true;

                    return columnDefinition;
                }
            }
        }
예제 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Columnid"/> class.
 /// </summary>
 /// <param name="columnbase">The column identifier.</param>
 internal Columnid(JET_COLUMNBASE columnbase)
     : this(columnbase.szBaseColumnName, columnbase.columnid, columnbase.coltyp, columnbase.cp == JET_CP.ASCII)
 {
 }
예제 #10
0
 public void JetColumnbaseToString()
 {
     var columndef = new JET_COLUMNBASE { coltyp = JET_coltyp.Text, grbit = ColumndefGrbit.ColumnFixed };
     Assert.AreEqual("JET_COLUMNBASE(Text,ColumnFixed)", columndef.ToString());
 }
예제 #11
0
        /// <summary>
        /// Creates a <see cref="ColumnDefinition"/> object representing the column passed in by <paramref name="columnBase"/>.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="columnBase">The <see cref="JET_COLUMNBASE"/> object that represents this particular column.</param>
        /// <returns>
        /// A <see cref="ColumnDefinition"/> object based on the <paramref name="columnBase"/> object.
        /// </returns>
        internal static ColumnDefinition Load(IsamDatabase database, string tableName, JET_COLUMNBASE columnBase)
        {
            lock (database.IsamSession)
            {
                using (IsamTransaction trx = new IsamTransaction(database.IsamSession))
                {
                    JET_SESID sesid = database.IsamSession.Sesid;

                    // load info for the column
                    ColumnDefinition columnDefinition = new ColumnDefinition();

                    columnDefinition.columnid = new Columnid(columnBase);
                    columnDefinition.name     = columnDefinition.columnid.Name;
                    columnDefinition.type     = columnDefinition.columnid.Type;

                    columnDefinition.flags = ColumnFlagsFromGrbits(columnBase.grbit);

                    columnDefinition.maxLength = (int)columnBase.cbMax;
                    columnDefinition.IsAscii   = columnBase.cp == JET_CP.ASCII;

                    // there is currently no efficient means to retrieve the
                    // default value of a specific column from JET.  so, we are
                    // going to reach into the catalog and fetch it directly
                    JET_TABLEID tableidCatalog;
                    Api.JetOpenTable(
                        sesid,
                        database.Dbid,
                        "MSysObjects",
                        null,
                        0,
                        OpenTableGrbit.ReadOnly,
                        out tableidCatalog);

                    Api.JetSetCurrentIndex(sesid, tableidCatalog, "RootObjects");
                    Api.MakeKey(sesid, tableidCatalog, true, MakeKeyGrbit.NewKey);
                    Api.MakeKey(
                        sesid,
                        tableidCatalog,
                        Converter.BytesFromObject(JET_coltyp.Text, true, columnBase.szBaseTableName),
                        MakeKeyGrbit.None);
                    Api.JetSeek(sesid, tableidCatalog, SeekGrbit.SeekEQ);
                    JET_COLUMNBASE columnbaseCatalog;
                    Api.JetGetTableColumnInfo(sesid, tableidCatalog, "ObjidTable", out columnbaseCatalog);
                    uint objidTable = Api.RetrieveColumnAsUInt32(sesid, tableidCatalog, columnbaseCatalog.columnid).GetValueOrDefault();

                    Api.JetSetCurrentIndex(sesid, tableidCatalog, "Name");
                    Api.MakeKey(sesid, tableidCatalog, objidTable, MakeKeyGrbit.NewKey);
                    Api.MakeKey(sesid, tableidCatalog, (short)2, MakeKeyGrbit.None);
                    Api.MakeKey(sesid, tableidCatalog, columnBase.szBaseColumnName, Encoding.ASCII, MakeKeyGrbit.None);
                    Api.JetSeek(sesid, tableidCatalog, SeekGrbit.SeekEQ);

                    Api.JetGetTableColumnInfo(sesid, tableidCatalog, "DefaultValue", out columnbaseCatalog);
                    byte[] defaultValueBytes = Api.RetrieveColumn(sesid, tableidCatalog, columnbaseCatalog.columnid);

                    Columnid isamColumnid = columnDefinition.columnid;
                    columnDefinition.defaultValue = Converter.ObjectFromBytes(
                        isamColumnid.Coltyp,
                        columnDefinition.IsAscii,
                        defaultValueBytes);

                    columnDefinition.ReadOnly = true;

                    return(columnDefinition);
                }
            }
        }
예제 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Columnid"/> class.
 /// </summary>
 /// <param name="columnbase">The column identifier.</param>
 internal Columnid(JET_COLUMNBASE columnbase)
     : this(columnbase.szBaseColumnName, columnbase.columnid, columnbase.coltyp, columnbase.cp == JET_CP.ASCII)
 {
 }