通过ShowModelContainer(缓存配置)和ID(关键字)获得Model

2017-05-28 13:56:52  访问(1581) 赞(0) 踩(0)


        #region 通过ShowModelContainer(缓存配置)和ID(关键字)获得Model

        /// <summary>
        /// 通过ShowModelContainer(缓存配置)和ID(关键字)获得Model
        /// </summary>
        /// <param name="dataPkId">关键字</param>
        /// <param name="SMC">数据容器</param>
        /// <param name="cacheFirst">是否缓存优先</param>
        /// <param name="xdbHelper">数据库链接串</param>
        /// <returns></returns>
        public BaseModel BaseModelGetBySMC
            (
                string dataPkId,
                ShowModelContainer SMC,
                bool cacheFirst,
                DBHelper xdbHelper
            )
        {
            if (dataPkId == null || dataPkId.Length == 0)
                return null;

            if (SMC == null)
            {
                return GetBaseModelByStrId4Cache(dataPkId, cacheFirst, xdbHelper);
            }

            string className
                =
                this.GetType().FullName;

            ShowModel showM = SMC.ShowModelFind
                (
                    className,
                    dataPkId
                );

            if (showM != null)
            {
                return showM.Data;
            }

            BaseModel
                model
                =
                this.GetBaseModelByStrId4Cache(dataPkId, cacheFirst, xdbHelper);
                

            SMC.ShowModelAdd
                (
                    className,
                    dataPkId,
                    model
                );

            return model;
        }

        #endregion 通过ShowModelContainer(缓存配置)和ID(关键字)获得Model


        #region 通过ShowModelContainer(缓存配置)和ID(关键字)获得Model对应的显示值

        /// <summary>
        /// 通过ShowModelContainer(缓存配置)和ID(关键字)获得Model对应的显示值
        /// </summary>
        /// <param name="dataPkId"></param>
        /// <param name="SMC">数据容器</param>
        /// <param name="cacheFirst">是否缓存优先</param>
        /// <param name="defaultValue">没有记录的返回值</param>
        /// <param name="xdbHelper">数据库链接串</param>
        /// <returns></returns>
        public string ShowNameGetBySMC
            (
                string dataPkId,
                ShowModelContainer SMC,
                bool cacheFirst,
                string defaultValue,
                DBHelper xdbHelper
            )
        {

            BaseModel
                model
                =
                BaseModelGetBySMC(dataPkId, SMC, cacheFirst, xdbHelper);

            if (model == null)
                return defaultValue;

            return model.GetShowName();

        }

        #endregion 通过ShowModelContainer(缓存配置)和ID(关键字)获得Model对应的显示值


上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)
 
  ┈全部┈  
 
(显示默认分类)