Example #1
0
 internal TableCollection(MapinfoSession MISession)
 {
     this.miSession    = MISession;
     this.tableinfo    = new TableInfoWrapper(MISession);
     this.mapbasic     = new MapbasicWrapper(MISession);
     this.tablefactory = new TableFactory(miSession);
 }
        /// <summary>
        /// Returns a new <see cref="Table{TEntity}"/> using the <typeparamref name="TEntity"/> as the
        /// tables row entity.
        ///
        /// <para>This function is usful if you have retrived an table from a <see cref="MapinfoSession"/>'s  <see cref="TableCollection"/>
        /// which are stored as <see cref="Table"/> but you know the entity type for it.</para>
        /// </summary>
        /// <typeparam name="TEntity">The type to use as the entity type for the table.</typeparam>
        /// <returns>A new <see cref="Table{TEntity}"/> for the same table as this <see cref="Table"/>.</returns>
        public Table <TEntity> ToGenericTable <TEntity>()
            where TEntity : BaseEntity, new()
        {
            TableFactory tabFactory = new TableFactory(this.mapinfo);

            // We can return a new generic version of the table here,
            // because we have overriden Equals and GetHashCode, making the
            // new table and this one equal.
            return(tabFactory.GetTableFor <TEntity>(this.Name));
        }