Ejemplo n.º 1
0
        public static BaseItemDetailsEntity GetObjectByCache(string tableName, string id)
        {
            BaseItemDetailsEntity result = null;

            string key = "ItemDetails:" + tableName;

            if (!string.IsNullOrEmpty(id))
            {
                key = "ItemDetails:" + tableName + ":" + id;
            }
            result = GetCache(key);

            if (result == null)
            {
                // 动态读取表中的数据
                BaseItemDetailsManager manager = new BaseItemDetailsManager(tableName);
                result = manager.GetObject(id);
                // 若是空的不用缓存,继续读取实体
                if (result != null)
                {
                    SetCache(tableName, result);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>数据表</returns>
        public BaseItemDetailsEntity GetObject(BaseUserInfo userInfo, string tableName, string id)
        {
            BaseItemDetailsEntity entity = null;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName);
                entity = itemDetailsManager.GetObject(id);
            });
            return(entity);
        }