/// <summary> /// 提交,修改 /// </summary> /// <param name="tandasEntity"></param> /// <param name="keyValue"></param> public void SubmitForm(ProfileSanitationCesspoolEntity cessEntity, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { cessEntity.Modify(keyValue); service.Update(cessEntity); try { //添加日志 LogMess.addLog(DbLogType.Update.ToString(), "修改成功", "修改环卫倒粪池小便池信息【" + cessEntity.Address + "】成功!"); } catch { } } else { cessEntity.Create(); service.Insert(cessEntity); try { //添加日志 LogMess.addLog(DbLogType.Update.ToString(), "修改成功", "新建环卫倒粪池小便池信息【" + cessEntity.Address + "】成功!"); } catch { } } }
/// <summary> /// 单条 /// 批量导入 /// </summary> /// <param name="entity"></param> /// <param name="skipWhere"></param> /// <param name="coverWhere"></param> public void BatchSubmitFrom(ProfileSanitationCesspoolEntity entity, Func <ProfileSanitationCesspoolEntity, ProfileSanitationCesspoolEntity, bool> skipWhere, Func <ProfileSanitationCesspoolEntity, ProfileSanitationCesspoolEntity, bool> coverWhere) { if (skipWhere != null) { Func <ProfileSanitationCesspoolEntity, bool> dbSkipWhere = db => skipWhere(db, entity); var dbSkipQuery = this.service.dbcontext.Set <ProfileSanitationCesspoolEntity>().Where(dbSkipWhere); if (dbSkipQuery.Count() > 0) { return; } } if (coverWhere != null) { Func <ProfileSanitationCesspoolEntity, bool> dbCoverWhere = db => coverWhere(db, entity); var dbCoverQuery = this.service.dbcontext.Set <ProfileSanitationCesspoolEntity>().Where(dbCoverWhere); if (dbCoverQuery.Count() > 0) { var dbEntity = dbCoverQuery.FirstOrDefault(); dbEntity.CityId = entity.CityId; dbEntity.CountyId = entity.CountyId; dbEntity.ProjectId = entity.ProjectId; dbEntity.StreetId = entity.StreetId; dbEntity.F_EnCode = entity.F_EnCode; dbEntity.Address = entity.Address; dbEntity.Modify(dbEntity.F_Id); this.service.Update(dbEntity); return; } } entity.Create(); this.service.Insert(entity); }