Ejemplo n.º 1
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="id">主键Id</param>
        /// <returns>DataAccess.Model.DUE00</returns>
        public DataAccess.Model.DUE00 GetModelForCache(long id)
        {
            try
            {
                //从缓存中读取指定Id记录
                var model = GetModelForCache(x => x.Id == id);

                if (model == null)
                {
                    //从数据库中读取
                    var tem = DUE00.SingleOrDefault(x => x.Id == id);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);
                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取DUE00表记录时出现异常", e);

                return(null);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取指定Id记录
 /// </summary>
 /// <param name="id">主键Id</param>
 /// <param name="isCache">是否从缓存中读取</param>
 /// <returns>DataAccess.Model.DUE00</returns>
 public DataAccess.Model.DUE00 GetModel(long id, bool isCache = true)
 {
     //判断是否使用缓存
     if (CommonBll.IsUseCache() && isCache)
     {
         //从缓存中获取List
         var list = GetList();
         if (list == null)
         {
             return(null);
         }
         else
         {
             //在List查询指定主键Id的记录
             return(list.SingleOrDefault(x => x.Id == id));
         }
     }
     else
     {
         //从数据库中直接读取
         var model = DUE00.SingleOrDefault(x => x.Id == id);
         if (model == null)
         {
             return(null);
         }
         else
         {
             //对查询出来的实体进行转换
             return(Transform(model));
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.DUE00</returns>
        public DataAccess.Model.DUE00 GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.DUE00           model      = null;
                Expression <Func <DUE00, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "SHOP_ID":
                    model      = list.SingleOrDefault(x => x.SHOP_ID == (string)value);
                    expression = x => x.SHOP_ID == (string)value;
                    break;

                case "TAKEIN_ID":
                    model      = list.SingleOrDefault(x => x.TAKEIN_ID == (string)value);
                    expression = x => x.TAKEIN_ID == (string)value;
                    break;

                case "STATUS":
                    model      = list.SingleOrDefault(x => x.STATUS == (byte)value);
                    expression = x => x.STATUS == (byte)value;
                    break;

                case "INPUT_DATE":
                    model      = list.SingleOrDefault(x => x.INPUT_DATE == (DateTime)value);
                    expression = x => x.INPUT_DATE == (DateTime)value;
                    break;

                case "SUP_ID":
                    model      = list.SingleOrDefault(x => x.SUP_ID == (string)value);
                    expression = x => x.SUP_ID == (string)value;
                    break;

                case "USER_ID":
                    model      = list.SingleOrDefault(x => x.USER_ID == (string)value);
                    expression = x => x.USER_ID == (string)value;
                    break;

                case "APP_USER":
                    model      = list.SingleOrDefault(x => x.APP_USER == (string)value);
                    expression = x => x.APP_USER == (string)value;
                    break;

                case "APP_DATETIME":
                    model      = list.SingleOrDefault(x => x.APP_DATETIME == (DateTime)value);
                    expression = x => x.APP_DATETIME == (DateTime)value;
                    break;

                case "TOT_AMOUNT":
                    model      = list.SingleOrDefault(x => x.TOT_AMOUNT == (decimal)value);
                    expression = x => x.TOT_AMOUNT == (decimal)value;
                    break;

                case "TOT_TAX":
                    model      = list.SingleOrDefault(x => x.TOT_TAX == (decimal)value);
                    expression = x => x.TOT_TAX == (decimal)value;
                    break;

                case "TOT_QTY":
                    model      = list.SingleOrDefault(x => x.TOT_QTY == (decimal)value);
                    expression = x => x.TOT_QTY == (decimal)value;
                    break;

                case "PRE_PAY":
                    model      = list.SingleOrDefault(x => x.PRE_PAY == (decimal)value);
                    expression = x => x.PRE_PAY == (decimal)value;
                    break;

                case "PRE_PAY_ID":
                    model      = list.SingleOrDefault(x => x.PRE_PAY_ID == (string)value);
                    expression = x => x.PRE_PAY_ID == (string)value;
                    break;

                case "RELATE_ID":
                    model      = list.SingleOrDefault(x => x.RELATE_ID == (string)value);
                    expression = x => x.RELATE_ID == (string)value;
                    break;

                case "INVOICE_ID":
                    model      = list.SingleOrDefault(x => x.INVOICE_ID == (string)value);
                    expression = x => x.INVOICE_ID == (string)value;
                    break;

                case "TAKEIN_TYPE":
                    model      = list.SingleOrDefault(x => x.TAKEIN_TYPE == (int)value);
                    expression = x => x.TAKEIN_TYPE == (int)value;
                    break;

                case "Memo":
                    model      = list.SingleOrDefault(x => x.Memo == (string)value);
                    expression = x => x.Memo == (string)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = DUE00.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取DUE00表记录时出现异常", e);

                return(null);
            }
        }