コード例 #1
0
ファイル: TableChecker.cs プロジェクト: guojianbin/buffalobro
        /// <summary>
        /// 检测表结构
        /// </summary>
        /// <param name="lstSql">需要更新的SQL</param>
        /// <param name="dbInfo">数据库信息</param>
        /// <param name="table">要检测的表</param>
        private static void CheckTableStruct(List <string> lstSql, DBInfo dbInfo, KeyWordTableParamItem table)
        {
            string                    tableName = table.TableName;
            BQLQuery                  bql       = BQL.Select(BQL.ToTable(tableName)._).From(BQL.ToTable(tableName));
            SelectCondition           con       = BQLKeyWordManager.ToCondition(bql, dbInfo, null, true) as SelectCondition;
            string                    sql       = dbInfo.CurrentDbAdapter.GetTopSelectSql(con, 1);
            Dictionary <string, bool> dic       = new Dictionary <string, bool>();

            using (IDataReader reader = dbInfo.DefaultOperate.Query(sql, new Buffalo.DB.DbCommon.ParamList(), null))
            {
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    dic[reader.GetName(i).ToLower()] = true;
                }
            }

            StringBuilder sbSql  = new StringBuilder();
            string        desSQL = null;
            IDBAdapter    idb    = dbInfo.CurrentDbAdapter;

            foreach (EntityParam pInfo in table.Params)
            {
                if (!dic.ContainsKey(pInfo.ParamName.ToLower()))
                {
                    dbInfo.DBStructure.OnCheckEvent(pInfo, dbInfo, CheckEvent.TablenBeginCheck, lstSql);
                    bql = BQL.AlterTable(tableName).AddParam(pInfo);
                    AbsCondition acon = BQLKeyWordManager.ToCondition(bql, dbInfo, null, true);
                    lstSql.Add(acon.GetSql(false));
                    if (!string.IsNullOrEmpty(pInfo.Description))//添加注释
                    {
                        desSQL = idb.GetAddDescriptionSQL(table, pInfo, dbInfo);
                        if (!string.IsNullOrEmpty(desSQL))
                        {
                            lstSql.Add(desSQL);
                        }
                    }
                    dbInfo.DBStructure.OnCheckEvent(pInfo, dbInfo, CheckEvent.TableChecked, lstSql);
                }
            }
        }
コード例 #2
0
ファイル: BQLDbBase.cs プロジェクト: guojianbin/buffalobro
 /// <summary>
 /// 直接查询数据库视图
 /// </summary>
 /// <param name="tableName">表名称</param>
 /// <param name="lstScope">条件</param>
 /// <param name="vParams">字段列表</param>
 /// <returns></returns>
 public virtual DataSet SelectTable(string tableName, ScopeList lstScope)
 {
     return(SelectTable(BQL.ToTable(tableName), lstScope));
 }