namespace X3Platform.CodeBuilder.Data
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Text;

    /// <summary>Êý¾Ý¿â½á¹¹Ìá¹©Æ÷</summary>
    public interface IDbSchemaProvider
    {
        /// <summary>Êý¾Ý¿âÁ¬½Ó×Ö·û´®</summary>
        string ConnectionString { get; set; }

        /// <summary>²éÑ¯Êý¾Ý¿âÃû³Æ</summary>
        /// <returns>Êý¾Ý¿âÃû³Æ</returns>
        string GetDatabaseName();

        /// <summary>²éÑ¯Êý¾Ý¿âÖÐ¶à¸ö±íµÄÐÅÏ¢</summary>
        /// <param name="databaseName">Êý¾Ý¿â</param>
        /// <param name="ownerName">ËùÓÐÕß</param>
        /// <param name="tableNames">±íÃû, ¶à¸öÒÔ°ë½Ç¶ººÅ¸ô¿ª</param>
        /// <returns>¶à¸öÊý¾Ý±íÐÅÏ¢µÄÁÐ±í</returns>
        IList<DataTableSchema> GetTables(string databaseName, string ownerName, string tableNames);

        /// <summary>²éÑ¯Êý¾Ý¿âÖÐ±íµÄÐÅÏ¢</summary>
        /// <param name="databaseName">Êý¾Ý¿â</param>
        /// <param name="ownerName">ËùÓÐÕß</param>
        /// <param name="tableName">±íÃû</param>
        /// <returns>Êý¾Ý±íÐÅÏ¢</returns>
        DataTableSchema GetTable(string databaseName, string ownerName, string tableName);

        /// <summary>²éÑ¯Êý¾Ý¿âÖÐ±íµÄ×Ö¶ÎÐÅÏ¢</summary>
        /// <param name="databaseName">Êý¾Ý¿â</param>
        /// <param name="ownerName">ËùÓÐÕß</param>
        /// <param name="tableName">±íÃû</param>
        /// <returns></returns>
        DataColumnSchemaCollection GetColumns(string databaseName, string ownerName, string tableName);

        /// <summary>²éÑ¯Êý¾Ý¿âÖÐ±íµÄÖ÷¼ü×Ö¶ÎÐÅÏ¢</summary>
        /// <param name="databaseName">Êý¾Ý¿â</param>
        /// <param name="ownerName">ËùÓÐÕß</param>
        /// <param name="tableName">±í</param>
        /// <returns></returns>
        DataColumnSchemaCollection GetPrimaryKeyColumns(string databaseName, string ownerName, string tableName);

        /// <summary>²éÑ¯Êý¾Ý¿âÖÐ±íµÄÍâ¼ü×Ö¶ÎÐÅÏ¢</summary>
        /// <param name="databaseName">Êý¾Ý¿â</param>
        /// <param name="ownerName">ËùÓÐÕß</param>
        /// <param name="tableName">±í</param>
        /// <returns>Íâ¼ü×Ö¶ÎÐÅÏ¢¼¯ºÏ</returns>
        DataColumnSchemaCollection GetForeignKeyColumns(string databaseName, string ownerName, string tableName);

        /// <summary>²éÑ¯Êý¾Ý¿âÖÐ±íµÄÖ÷¼üÒâÍâµÄ×Ö¶ÎÐÅÏ¢</summary>
        /// <param name="databaseName">Êý¾Ý¿â</param>
        /// <param name="ownerName">ËùÓÐÕß</param>
        /// <param name="tableName">±í</param>
        /// <returns></returns>
        DataColumnSchemaCollection GetNoPrimaryKeyColumns(DataTableSchema table);

        /// <summary>ÉèÖÃÊý¾ÝÀàÐÍ</summary>
        /// <param name="type"></param>
        /// <returns></returns>
        DbType SetDataType(string type);

        /// <summary>»ñÈ¡Êý¾ÝÀàÐÍ</summary>
        /// <param name="type"></param>
        /// <returns></returns>
        string GetDataType(DbType type);
    }
}
