Beispiel #1
0
        public static T_School GetSchool(int schoolId)
        {
            T_School model = null;

            using (MySqlDataReader dr = MySqlHelper.ExecuteReader(Util.GetConnectString(BaseConnString),
                                                                  "select SchoolId, SchoolName from T_School where SchoolId = @SchoolId",
                                                                  "@SchoolId".ToInt32InPara(schoolId)))
            {
                if (dr != null && dr.HasRows)
                {
                    model = MySqlDBHelper.ConvertDataReaderToEntitySingle <T_School>(dr);
                }
            }
            return(model);
        }
Beispiel #2
0
        /// <summary>
        /// 获取学校
        /// </summary>
        /// <param name="schoolId"></param>
        /// <returns></returns>
        public static T_School GetSchool(int schoolId)
        {
            T_School tempresult = null;

            string key = RedisHelper.GetEasyZyRedisKey(CacheCatalog.Base, "SCH_" + schoolId.ToString());

            using (var client = RedisHelper.Instance.GetRedisClient(CacheCatalog.Base.ToString()))
            {
                if (client != null)
                {
                    tempresult = client.Get <T_School>(key);
                    if (tempresult == null)
                    {
                        tempresult = B_Base.GetSchool(schoolId);
                        if (tempresult != null)
                        {
                            client.Set <T_School>(key, tempresult, ts);
                        }
                    }
                }
            }

            return(tempresult);
        }