コード例 #1
0
ファイル: ContentMgr.cs プロジェクト: uvbs/Asda2-Server
        /// <summary>Checks the validity of all Table definitions</summary>
        /// <returns>The amount of invalid columns.</returns>
        public static int Check(Action <string> feedbackCallback)
        {
            ContentMgr.EnsureInitialized();
            int num = 0;

            foreach (LightDBMapper lightDbMapper in ContentMgr.s_mappersByType.Values)
            {
                foreach (TableDefinition tableDefinition in lightDbMapper.Mapping.TableDefinitions)
                {
                    foreach (SimpleDataColumn columnDefinition in tableDefinition.ColumnDefinitions)
                    {
                        if (!columnDefinition.IsEmpty)
                        {
                            try
                            {
                                using (lightDbMapper.Wrapper.Query(SqlUtil.BuildSelect(new string[1]
                                {
                                    columnDefinition.ColumnName
                                }, tableDefinition.Name, "LIMIT 1")))
                                    ;
                            }
                            catch (Exception ex)
                            {
                                feedbackCallback(string.Format("Invalid column \"{0}\" in table \"{1}\": {2}",
                                                               (object)columnDefinition, (object)tableDefinition.Name,
                                                               (object)ex.GetAllMessages().ToString <string>("\n\t")));
                                ++num;
                            }
                        }
                    }
                }
            }

            return(num);
        }
コード例 #2
0
        /// <summary>
        /// Should return a version string in the format of a float.
        /// </summary>
        public string GetDatabaseVersion(string tableName, string columnName)
        {
            var reader = Query(SqlUtil.BuildSelect(new[] { columnName }, tableName));

            reader.Read();
            return(reader.GetValue(0).ToString());
        }
コード例 #3
0
ファイル: ContentMgr.cs プロジェクト: NecroSharper/WCell
        /// <summary>
        /// Checks the validity of all Table definitions
        /// </summary>
        /// <returns>The amount of invalid columns.</returns>
        public static int Check(Action <string> feedbackCallback)
        {
            EnsureInitialized();
            var count = 0;

            foreach (var mapper in s_mappersByType.Values)
            {
                foreach (var table in mapper.Mapping.TableDefinitions)
                {
                    var fields = table.ColumnDefinitions;
                    foreach (var field in fields)
                    {
                        if (!field.IsEmpty)
                        {
                            try
                            {
                                using (                                 //var reader =
                                    mapper.Wrapper.Query(SqlUtil.BuildSelect(new[] { field.ColumnName }, table.Name, "LIMIT 1")))
                                {
                                }
                            }
                            catch (Exception e)
                            {
                                feedbackCallback(
                                    string.Format("Invalid column \"{0}\" in table \"{1}\": {2}", field, table.Name,
                                                  e.GetAllMessages().ToString("\n\t")));
                                count++;
                            }
                        }
                    }
                }
            }
            return(count);
        }
コード例 #4
0
        /// <summary>
        /// Should return a version string in the format of a float.
        /// </summary>
        public string GetDatabaseVersion(string tableName, string columnName)
        {
            IDataReader dataReader = this.Query(SqlUtil.BuildSelect(new string[1]
            {
                columnName
            }, tableName));

            dataReader.Read();
            return(dataReader.GetValue(0).ToString());
        }
コード例 #5
0
 public void Prepare(LightDBMapper mapper)
 {
     TableDefinition[] tableDefinitions = mapper.Mapping.TableDefinitions;
     m_selectCommands = new IDbCommand[tableDefinitions.Length];
     for (int index = 0; index < tableDefinitions.Length; ++index)
     {
         TableDefinition tableDefinition = tableDefinitions[index];
         IDbCommand      command         =
             CreateCommand(SqlUtil.BuildSelect(tableDefinition.AllColumns, tableDefinition.Name));
         m_selectCommands[index] = command;
     }
 }
コード例 #6
0
        public void Prepare(LightDBMapper mapper)
        {
            var tables = mapper.Mapping.TableDefinitions;

            m_selectCommands = new IDbCommand[tables.Length];
            for (var i = 0; i < tables.Length; i++)
            {
                var table = tables[i];
                var cmd   = CreateCommand(SqlUtil.BuildSelect(table.AllColumns, table.Name)
                                          //+ " ORDER BY " + table.PrimaryColumns[0].Name
                                          );
                //tables[i].QueryString, emptySqlTypeArr);
                m_selectCommands[i] = cmd;
            }
        }