/// <summary> /// 更新IIS缓存中指定Id记录 /// </summary> /// <param name="model">记录实体</param> public void SetModelForCache(DataAccess.Model.SHOP_PAY_HISOTRY model) { //从缓存中读取记录列表 var list = GetList(); //从缓存中删除记录 DelCache(model.Id); //添加记录 list.Add(model); }
/// <summary> /// 给实体赋值 /// </summary> /// <param name="model">实体</param> /// <param name="dic">列名与值</param> public void SetModelValue(DataAccess.Model.SHOP_PAY_HISOTRY model, Dictionary <string, object> dic) { if (model == null || dic == null) { return; } //遍历字典,逐个给字段赋值 foreach (var d in dic) { SetModelValue(model, d.Key, d.Value); } }
/// <summary> /// 给实体赋值 /// </summary> /// <param name="model">实体</param> /// <param name="colName">列名</param> /// <param name="value">值</param> public void SetModelValue(DataAccess.Model.SHOP_PAY_HISOTRY model, string colName, object value) { if (model == null || string.IsNullOrEmpty(colName)) { return; } //返回指定条件的实体 switch (colName) { case "Id": model.Id = (int)value; break; case "SHOP_ID": model.SHOP_ID = (string)value; break; case "Head_SHOP_ID": model.Head_SHOP_ID = (string)value; break; case "BILL_ID": model.BILL_ID = (long)value; break; case "AMOUNT": model.AMOUNT = (string)value; break; case "PAY_DATE": model.PAY_DATE = (DateTime)value; break; case "PAYER": model.PAYER = (string)value; break; case "Memo": model.Memo = (string)value; break; case "CRT_DATETIME": model.CRT_DATETIME = (DateTime)value; break; case "CRT_USER_ID": model.CRT_USER_ID = (string)value; break; } }
/// <summary> /// 返回实体中指定字段名的值 /// </summary> /// <param name="model">实体</param> /// <param name="colName">获取的字段名</param> /// <returns></returns> private object GetFieldValue(DataAccess.Model.SHOP_PAY_HISOTRY model, string colName) { if (model == null || string.IsNullOrEmpty(colName)) { return(null); } //返回指定的列值 switch (colName) { case "Id": return(model.Id); case "SHOP_ID": return(model.SHOP_ID); case "Head_SHOP_ID": return(model.Head_SHOP_ID); case "BILL_ID": return(model.BILL_ID); case "AMOUNT": return(model.AMOUNT); case "PAY_DATE": return(model.PAY_DATE); case "PAYER": return(model.PAYER); case "Memo": return(model.Memo); case "CRT_DATETIME": return(model.CRT_DATETIME); case "CRT_USER_ID": return(model.CRT_USER_ID); } return(null); }
/// <summary> /// 将SHOP_PAY_HISOTRY记录实体由普通的实体(DataAccess.Model.SHOP_PAY_HISOTRY)转换为SubSonic插件生成的实体 /// </summary> /// <param name="model">普通的实体(DataAccess.Model.SHOP_PAY_HISOTRY)</param> /// <returns>SHOP_PAY_HISOTRY</returns> public SHOP_PAY_HISOTRY Transform(DataAccess.Model.SHOP_PAY_HISOTRY model) { if (model == null) { return(null); } return(new SHOP_PAY_HISOTRY { Id = model.Id, SHOP_ID = model.SHOP_ID, Head_SHOP_ID = model.Head_SHOP_ID, BILL_ID = model.BILL_ID, AMOUNT = model.AMOUNT, PAY_DATE = model.PAY_DATE, PAYER = model.PAYER, Memo = model.Memo, CRT_DATETIME = model.CRT_DATETIME, CRT_USER_ID = model.CRT_USER_ID, }); }
/// <summary> /// 从IIS缓存中获取指定Id记录 /// </summary> /// <param name="conditionColName">条件列名</param> /// <param name="value">条件值</param> /// <returns>DataAccess.Model.SHOP_PAY_HISOTRY</returns> public DataAccess.Model.SHOP_PAY_HISOTRY GetModelForCache(string conditionColName, object value) { try { //从缓存中获取List var list = GetList(); DataAccess.Model.SHOP_PAY_HISOTRY model = null; Expression <Func <SHOP_PAY_HISOTRY, 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 "Head_SHOP_ID": model = list.SingleOrDefault(x => x.Head_SHOP_ID == (string)value); expression = x => x.Head_SHOP_ID == (string)value; break; case "BILL_ID": model = list.SingleOrDefault(x => x.BILL_ID == (long)value); expression = x => x.BILL_ID == (long)value; break; case "AMOUNT": model = list.SingleOrDefault(x => x.AMOUNT == (string)value); expression = x => x.AMOUNT == (string)value; break; case "PAY_DATE": model = list.SingleOrDefault(x => x.PAY_DATE == (DateTime)value); expression = x => x.PAY_DATE == (DateTime)value; break; case "PAYER": model = list.SingleOrDefault(x => x.PAYER == (string)value); expression = x => x.PAYER == (string)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; default: return(null); } if (model == null) { //从数据库中读取 var tem = SHOP_PAY_HISOTRY.SingleOrDefault(expression); if (tem == null) { return(null); } else { //对查询出来的实体进行转换 model = Transform(tem); return(model); } } else { return(model); } } catch (Exception e) { //记录日志 CommonBll.WriteLog("从IIS缓存中获取SHOP_PAY_HISOTRY表记录时出现异常", e); return(null); } }