//-----------------------------------------------------------------------
// 
//     Copyright (c) Microsoft Corporation.
// 
//-----------------------------------------------------------------------
namespace Microsoft.Isam.Esent.Interop
{
    /// 
    /// Enumerate columns in a table specified by dbid and name.
    /// 
    internal sealed class TableColumnInfoEnumerator : ColumnInfoEnumerator
    {
        /// 
        /// The database containing the table.
        /// 
        private readonly JET_DBID dbid;
        /// 
        /// The name of the table.
        /// 
        private readonly string tablename;
        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// 
        /// The session to use.
        /// 
        /// 
        /// The database containing the table.
        /// 
        /// 
        /// The name of the table.
        /// 
        public TableColumnInfoEnumerator(JET_SESID sesid, JET_DBID dbid, string tablename) : base(sesid)
        {
            this.dbid = dbid;
            this.tablename = tablename;
        }
        /// 
        /// Open the table to be enumerated. This should set .
        /// 
        protected override void OpenTable()
        {
            JET_COLUMNLIST columnlist;
            Api.JetGetColumnInfo(this.Sesid, this.dbid, this.tablename, string.Empty, out columnlist);
            this.Columnlist = columnlist;
            this.TableidToEnumerate = this.Columnlist.tableid;
        }
    }
}