/// <summary> /// 更新IIS缓存中指定Id记录 /// </summary> /// <param name="model">记录实体</param> public void SetModelForCache(DataAccess.Model.SHOP_PRICE_AREA model) { //从缓存中读取记录列表 var list = GetList(); //从缓存中删除记录 DelCache(model.Id); //添加记录 list.Add(model); }
/// <summary> /// 给实体赋值 /// </summary> /// <param name="model">实体</param> /// <param name="colName">列名</param> /// <param name="value">值</param> public void SetModelValue(DataAccess.Model.SHOP_PRICE_AREA model, string colName, object value) { if (model == null || string.IsNullOrEmpty(colName)) { return; } //返回指定条件的实体 switch (colName) { case "Id": model.Id = (int)value; break; case "PRCAREA_ID": model.PRCAREA_ID = (string)value; break; case "PRCAREA_NAME": model.PRCAREA_NAME = (string)value; break; case "ENABLE": model.ENABLE = ConvertHelper.Ctinyint(value); break; case "PRCAREA_MEMO": model.PRCAREA_MEMO = (string)value; break; case "CRT_DATETIME": model.CRT_DATETIME = (DateTime)value; break; case "CRT_USER_ID": model.CRT_USER_ID = (string)value; break; case "MOD_DATETIME": model.MOD_DATETIME = (DateTime)value; break; case "MOD_USER_ID": model.MOD_USER_ID = (string)value; break; case "LAST_UPDATE": model.LAST_UPDATE = (DateTime)value; break; case "STATUS": model.STATUS = ConvertHelper.Ctinyint(value); break; } }
/// <summary> /// 给实体赋值 /// </summary> /// <param name="model">实体</param> /// <param name="dic">列名与值</param> public void SetModelValue(DataAccess.Model.SHOP_PRICE_AREA 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> /// <returns></returns> private object GetFieldValue(DataAccess.Model.SHOP_PRICE_AREA model, string colName) { if (model == null || string.IsNullOrEmpty(colName)) { return(null); } //返回指定的列值 switch (colName) { case "Id": return(model.Id); case "PRCAREA_ID": return(model.PRCAREA_ID); case "PRCAREA_NAME": return(model.PRCAREA_NAME); case "ENABLE": return(model.ENABLE); case "PRCAREA_MEMO": return(model.PRCAREA_MEMO); case "CRT_DATETIME": return(model.CRT_DATETIME); case "CRT_USER_ID": return(model.CRT_USER_ID); case "MOD_DATETIME": return(model.MOD_DATETIME); case "MOD_USER_ID": return(model.MOD_USER_ID); case "LAST_UPDATE": return(model.LAST_UPDATE); case "STATUS": return(model.STATUS); } return(null); }
/// <summary> /// 将SHOP_PRICE_AREA记录实体由普通的实体(DataAccess.Model.SHOP_PRICE_AREA)转换为SubSonic插件生成的实体 /// </summary> /// <param name="model">普通的实体(DataAccess.Model.SHOP_PRICE_AREA)</param> /// <returns>SHOP_PRICE_AREA</returns> public SHOP_PRICE_AREA Transform(DataAccess.Model.SHOP_PRICE_AREA model) { if (model == null) { return(null); } return(new SHOP_PRICE_AREA { Id = model.Id, PRCAREA_ID = model.PRCAREA_ID, PRCAREA_NAME = model.PRCAREA_NAME, ENABLE = model.ENABLE, PRCAREA_MEMO = model.PRCAREA_MEMO, CRT_DATETIME = model.CRT_DATETIME, CRT_USER_ID = model.CRT_USER_ID, MOD_DATETIME = model.MOD_DATETIME, MOD_USER_ID = model.MOD_USER_ID, LAST_UPDATE = model.LAST_UPDATE, STATUS = model.STATUS, }); }
/// <summary> /// 从IIS缓存中获取指定Id记录 /// </summary> /// <param name="conditionColName">条件列名</param> /// <param name="value">条件值</param> /// <returns>DataAccess.Model.SHOP_PRICE_AREA</returns> public DataAccess.Model.SHOP_PRICE_AREA GetModelForCache(string conditionColName, object value) { try { //从缓存中获取List var list = GetList(); DataAccess.Model.SHOP_PRICE_AREA model = null; Expression <Func <SHOP_PRICE_AREA, bool> > expression = null; //返回指定条件的实体 switch (conditionColName) { case "Id": model = list.SingleOrDefault(x => x.Id == (int)value); expression = x => x.Id == (int)value; break; case "PRCAREA_ID": model = list.SingleOrDefault(x => x.PRCAREA_ID == (string)value); expression = x => x.PRCAREA_ID == (string)value; break; case "PRCAREA_NAME": model = list.SingleOrDefault(x => x.PRCAREA_NAME == (string)value); expression = x => x.PRCAREA_NAME == (string)value; break; case "ENABLE": model = list.SingleOrDefault(x => x.ENABLE == (byte)value); expression = x => x.ENABLE == (byte)value; break; case "PRCAREA_MEMO": model = list.SingleOrDefault(x => x.PRCAREA_MEMO == (string)value); expression = x => x.PRCAREA_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; case "STATUS": model = list.SingleOrDefault(x => x.STATUS == (byte)value); expression = x => x.STATUS == (byte)value; break; default: return(null); } if (model == null) { //从数据库中读取 var tem = SHOP_PRICE_AREA.SingleOrDefault(expression); if (tem == null) { return(null); } else { //对查询出来的实体进行转换 model = Transform(tem); return(model); } } else { return(model); } } catch (Exception e) { //记录日志 CommonBll.WriteLog("从IIS缓存中获取SHOP_PRICE_AREA表记录时出现异常", e); return(null); } }