示例#1
0
 /// <summary>
 /// 初始化所有的表并创建没有的表
 /// </summary>
 /// <returns></returns>
 internal bool InitAllTables()
 {
     Open();
     try
     {
         Type[]      ts    = this.GetType().Assembly.GetTypes();
         List <Type> types = ts.Where(t => t.BaseType != null && t.BaseType.Namespace.Equals(assembly) && t.BaseType.Name.Equals(typeof(SqliteDataTableBase).Name) && t.IsClass)
                             .Select(tt => tt).ToList();
         foreach (var t in types)
         {
             string tablename = SqliteTabelCmdStrTool.GetTableName(t);
             if (!CheckTable(tablename))
             {
                 string cmdStr = SqliteTabelCmdStrTool.GetCreateTableCmdStr(t, true, true);
                 OperateRecords(cmdStr);
             }
         }
         return(true);
     }
     catch (SqliteException e)
     {
         LogOperator.AddWarnningRecord("检查所有的表并创建没有的表时异常", e.Message);
         return(false);
     }
 }
示例#2
0
 /// <summary>
 /// 检查表是否存在
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="type"></param>
 /// <returns></returns>
 internal bool CheckTable(Type type)
 {
     return(CheckTable(SqliteTabelCmdStrTool.GetTableName(type)));
 }