示例#1
0
        /// <summary>
        /// 从已加载的数据中获取对应类型的List<>, 如果对应类型不存在, 加载并返回加载后的结果
        /// </summary>
        private IList GetSubItemList(Type type, IDbAccessorFactory dbAcsFty, object key)
        {
            ClassDesc   clsDesc    = GetClassDesc(type);
            IDbAccessor dbAccessor = dbAcsFty.GetDbAccessor(clsDesc.TableName);
            IDataReader reader     = dbAccessor.Query(GetQueryString(clsDesc.TableName, clsDesc.RootKeyAttribute.ColumnName, key));
            IList       list       = ReadItems(type, reader, clsDesc, dbAcsFty, key);

            dbAccessor.CloseDbReader();
            return(list);
        }
示例#2
0
 /// <summary>
 /// 获取整个表中的所有数据
 /// </summary>
 public List <T> QueryAllData <T>(IDbAccessorFactory dbAcsFty) where T : class, new()
 {
     try
     {
         ClassDesc   clsDesc    = GetClassDesc(typeof(T));
         IDbAccessor dbAccessor = dbAcsFty.GetDbAccessor(clsDesc.TableName);
         IDataReader reader     = dbAccessor.Query(GetQueryString(clsDesc.TableName, clsDesc.KeyAttribute.ColumnName, null));
         List <T>    result     = ReadItems <T>(reader, clsDesc, dbAcsFty, null);
         dbAccessor.CloseDbReader();
         return(result);
     }
     catch (Exception e)
     {
         var sb = new StringBuilder();
         sb.AppendLine(e.Message);
         sb.AppendLine(e.StackTrace);
         Debug.LogError(sb.ToString());
         return(new List <T>());
     }
 }
示例#3
0
        private static string GetValue(string name)
        {
            string result = string.Empty;

            try
            {
                IDbAccessor dbAccessor = ConfigDataBase.Instance.DbAccessorFactory.GetDbAccessor("const_value");
                IDataReader reader     = dbAccessor.Query("select `value` from `const_value` where `key`='" + name + "'");

                if (reader.Read())
                {
                    result = reader.GetValue(0).ToString();
                }
                dbAccessor.CloseDbReader();
            }
            catch (Exception e)
            {
                Debug.LogError("ConstValue.GetValue found " + e.ToString() + " when read " + name);
            }

            return(result);
        }