JetGetIndexInfo() public static méthode

Retrieves information about indexes on a table.
public static JetGetIndexInfo ( JET_SESID sesid, JET_DBID dbid, string tablename, string ignored, JET_INDEXLIST &indexlist ) : void
sesid JET_SESID The session to use.
dbid JET_DBID The database to use.
tablename string The name of the table to retrieve index information about.
ignored string This parameter is ignored.
indexlist JET_INDEXLIST Filled in with information about indexes on the table.
Résultat void
Exemple #1
0
        public IEnumerable <DBRow> GetIndexInfo(string tableName, string indexName)
        {
            IEnumerable <ColSpec> tableDef = GetIndexTableDef(tableName, indexName);

            JET_INDEXLIST indexList;

            Esent.JetGetIndexInfo(m_sesid, m_dbid, tableName, indexName, out indexList, JET_IdxInfo.List);

            var columnsByName = new Dictionary <string, int>();
            int i             = 0;

            foreach (ColSpec column in tableDef)
            {
                columnsByName.Add(column.Name, i++);
            }

            Esent.JetMove(m_sesid, indexList.tableid, JET_Move.First, MoveGrbit.None);

            i = 0;
            do
            {
                var row = new List <object>();

                foreach (ColSpec column in tableDef)
                {
                    row.Add(column.Retriever(m_sesid, indexList.tableid, column.ColumnId));
                }

                yield return(new DBRow(columnsByName, row, i++));
            }while (Esent.TryMoveNext(m_sesid, indexList.tableid));

            Esent.JetCloseTable(m_sesid, indexList.tableid);
        }
Exemple #2
0
 public static void JetGetIndexInfo(
     JET_SESID sesid,
     JET_DBID dbid,
     string tablename,
     string ignored,
     out JET_INDEXLIST indexlist)
 {
     Api.JetGetIndexInfo(sesid, dbid, tablename, ignored, out indexlist, JET_IdxInfo.List);
 }
Exemple #3
0
        private IEnumerable <ColSpec> GetIndexTableDef(string tableName, string indexName)
        {
            JET_INDEXLIST indexList;

            Esent.JetGetIndexInfo(m_sesid, m_dbid, tableName, indexName, out indexList, JET_IdxInfo.List);

            // Unfortunately, Esent.GetTableColumns doesn't work on the temporary table returned by
            // JetGetIndexInfo, but the JET_INDEXLIST and the documentation have all the
            // information we need.
            var tableDef = new ColSpec[] {
                new ColSpec
                {
                    Name     = "Columns",
                    Type     = typeof(Int32?),
                    ColumnId = indexList.columnidcColumn
                },
                new ColSpec
                {
                    Name     = "Entries",
                    Type     = typeof(Int32?),
                    ColumnId = indexList.columnidcEntry
                },
                new ColSpec
                {
                    Name     = "UniqueKeys",
                    Type     = typeof(Int32?),
                    ColumnId = indexList.columnidcKey
                },
                new ColSpec {
                    Name     = "Coltyp",
                    Type     = typeof(Int32?),
                    ColumnId = indexList.columnidcoltyp
                },
                new ColSpec {
                    Name     = "ColumnId",
                    Type     = typeof(Int32?),
                    ColumnId = indexList.columnidcolumnid
                },
                new ColSpec {
                    Name     = "ColumnName",
                    Type     = typeof(string),
                    ColumnId = indexList.columnidcolumnname
                },
                new ColSpec {
                    Name     = "CodePage",
                    Type     = typeof(Int16?),
                    ColumnId = indexList.columnidCp
                },
                new ColSpec {
                    Name     = "NumPages",
                    Type     = typeof(Int32?),
                    ColumnId = indexList.columnidcPage
                },
                new ColSpec {
                    Name     = "grbitColumn",
                    Type     = typeof(Int32?),
                    ColumnId = indexList.columnidgrbitColumn
                },
                new ColSpec {
                    Name     = "grbitIndex",
                    Type     = typeof(Int32?),
                    ColumnId = indexList.columnidgrbitIndex
                },
                new ColSpec {
                    Name     = "iColumn",
                    Type     = typeof(Int32?),
                    ColumnId = indexList.columnidiColumn
                },
                new ColSpec {
                    Name     = "IndexName",
                    Type     = typeof(string),
                    ColumnId = indexList.columnidindexname
                },
                new ColSpec {
                    Name     = "LangId",
                    Type     = typeof(Int16?),
                    ColumnId = indexList.columnidLangid
                },
                new ColSpec {
                    Name     = "LCMapFlags",
                    Type     = typeof(Int32?),
                    ColumnId = indexList.columnidLCMapFlags
                }
            };

            for (int i = 0, n = tableDef.Length; i < n; i++)
            {
                tableDef[i].Retriever = ColumnRetrievers.ForType(tableDef[i].Type);
            }

            Esent.JetCloseTable(m_sesid, indexList.tableid);

            return(tableDef);
        }