Esempio n. 1
0
        public List <string> LoadDataTypeList(DatabaseConfig config = null)
        {
            var typeList = new List <string>();

            // 生成SQL
            var sql = new ZinSQL("game_data");

            sql.AddField("DataType");
            sql.Config = config;

            var dataList = MySqlServer.Instance().GetList(sql);

            foreach (var data in dataList)
            {
                typeList.Add((string)data[0]);
            }
            return(typeList);
        }
Esempio n. 2
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        public T LoadData <T>(string type, DatabaseConfig config = null)
            where T : new()
        {
            // 生成SQL
            var sql = new ZinSQL("game_data");

            sql.AddField("DataValue");
            sql.SetQuery("DataType", type);
            sql.Config = config;

            // 获取数据
            var data = Get(sql);

            if (data != null && data[0] != DBNull.Value)
            {
                var value = SerializationHelper.Deserialize <T>((byte[])data[0]);
                if (value != null)
                {
                    return(value);
                }
            }

            return(new T());
        }