Beispiel #1
0
        /// <summary>
        /// 获取所有排序后的符合条件的数据表行。
        /// </summary>
        /// <param name="condition" > 要检查的条件。</param>
        /// <param name="comparison" > 要排序的条件。</param>
        /// <returns>所有排序后的符合条件的数据表行。</returns>
        public DTMySQL_Test[] GetAllDataRows(System.Predicate <DTMySQL_Test> condition, System.Comparison <DTMySQL_Test> comparison)
        {
            if (condition == null)
            {
                throw new System.Exception("Condition is invalid.");
            }

            if (comparison == null)
            {
                throw new System.Exception("Comparison is invalid.");
            }

            List <DTMySQL_Test> results = new List <DTMySQL_Test>();

            foreach (var dataRow in _dict)
            {
                DTMySQL_Test dr = dataRow.Value;
                if (condition(dr))
                {
                    results.Add(dr);
                }
            }

            results.Sort(comparison);
            return(results.ToArray());
        }
Beispiel #2
0
        public void CloneAll(DTMySQL_Test c)
        {
            Id = c.Id;

            Value1 = c.Value1;

            Value = c.Value;
        }
Beispiel #3
0
        /// <summary>
        /// 获取所有数据表行。
        /// </summary>
        /// <returns>所有数据表行。</returns>
        public DTMySQL_Test[] GetAllDataRows()
        {
            int index = 0;

            DTMySQL_Test[] allDataRows = new DTMySQL_Test[Count];
            foreach (var dataRow in _dict)
            {
                allDataRows[index++] = dataRow.Value;
            }

            return(allDataRows);
        }
Beispiel #4
0
        public static List <DTMySQL_Test> LoadBy_MySQLComText(string commandText)
        {
            List <DTMySQL_Test> testTempList = new List <DTMySQL_Test>();

            System.Data.DataTable dt = DatabaseManager.GetInstance().GetSQLSelectDataTable(commandText);
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    DTMySQL_Test temp = new DTMySQL_Test(dr);
                    testTempList.Add(temp);
                }
            }

            return(testTempList);
        }
Beispiel #5
0
        /// <summary>
        /// 获取符合条件的数据表行。
        /// </summary>
        /// <param name="condition" > 要检查的条件。</param>
        /// <returns>符合条件的数据表行。</returns>
        /// <remarks>当存在多个符合条件的数据表行时,仅返回第一个符合条件的数据表行。</remarks>
        public DTMySQL_Test GetDataRow(System.Predicate <DTMySQL_Test> condition)
        {
            if (condition == null)
            {
                throw new System.Exception("Condition is invalid.");
            }

            foreach (var dataRow in _dict)
            {
                DTMySQL_Test dr = dataRow.Value;
                if (condition(dr))
                {
                    return(dr);
                }
            }

            return(null);
        }
Beispiel #6
0
        /// <summary>
        /// Do reload the dataTable file: Test
        /// </summary>
        internal void ReloadAll(bool throwWhenDuplicatePrimaryKey, string customContent = null)
        {
            for (var j = 0; j < TabFilePaths.Length; j++)
            {
                var       tabFilePath = TabFilePaths[j];
                TableFile tableFile;
                if (customContent == null)
                {
                    tableFile = DTMySqlModule.Get(tabFilePath, false);
                }
                else
                {
                    tableFile = TableFile.LoadFromString(customContent);
                }

                using (tableFile)
                {
                    foreach (var row in tableFile)
                    {
                        DTMySQL_Test dataTable;
                        dataTable = new DTMySQL_Test(row);
                        if (!_dict.ContainsKey(dataTable.Id))
                        {
                            dataTable.UpdateToMySQL();
                            _dict[dataTable.Id] = dataTable;
                        }
                        else
                        {
                            if (throwWhenDuplicatePrimaryKey)
                            {
                                throw new System.Exception(string.Format("DuplicateKey, Class: {0}, File: {1}, Key: {2}", this.GetType().Name, tabFilePath, "Id"));
                            }
                            else
                            {
                                dataTable.Reload(row);
                            }
                        }
                    }
                }
            }
            //UnityEngine.Debug.LogFormat("Reload dataTables: {0}, Row Count: {1}, Reload Count: {2}", GetType(), Count);
        }
Beispiel #7
0
        private List <DTMySQL_Test> LoadBy_MySQLComTextInternal(string commandText)
        {
            List <DTMySQL_Test> testTempList = new List <DTMySQL_Test>();

            UnityEngine.Debug.Log("Load: " + commandText);
            System.Data.DataTable dt = DatabaseManager.GetInstance().GetSQLSelectDataTable(commandText);
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    DTMySQL_Test temp = new DTMySQL_Test(dr);
                    testTempList.Add(temp);
                    if (!_dict.ContainsKey(temp.Id))
                    {
                        _dict.Add(temp.Id, temp);
                    }
                }
            }

            return(testTempList);
        }
Beispiel #8
0
 public void CloneButId(DTMySQL_Test c)
 {
     Value1 = c.Value1;
     Value  = c.Value;
 }
Beispiel #9
0
 public void Clone(DTMySQL_Test c)
 {
     Id = c.Id;
 }