Esempio n. 1
0
        /// <summary>
        /// 判断sqlite文件中表是否存在
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        private bool IsTbExist(string tableName, string connectionString)
        {
            string checkTable = "select count(*) from sqlite_master where name='" + tableName + "' and type='table'";

            try
            {
                SqliteContext sqliteContext = new SqliteContext(new DBContextBridge
                {
                    ConnectionString = connectionString,
                    Provider         = "sqlite",
                });
                int r = Convert.ToInt32(sqliteContext.ExecuteScalar(checkTable));
                if (r < 1)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("判断sqlite文件中表是否存在时出现异常", ex);
            }
        }