/// <summary> /// 获取数据。此数据会持续增长,所以不建议一次性缓存。建议单个Model实体缓存。 /// </summary> public BaseResult GetUser(TestTableParam param) { var where = new Where <TestTable>(); #region 模糊搜索条件 if (!string.IsNullOrWhiteSpace(param.SearchName)) { where.And(d => d.Name.Like(param.SearchName)); } if (!string.IsNullOrWhiteSpace(param.SearchIDNumber)) { where.And(d => d.IDNumber.Like(param.SearchIDNumber)); } if (!string.IsNullOrWhiteSpace(param.SearchMobilePhone)) { where.And(d => d.MobilePhone.Like(param.SearchMobilePhone)); } #endregion #region 是否分页 var dateCount = 0; if (param._PageIndex != null && param._PageSize != null) { //取总数,以计算共多少页。自行考虑将总数缓存。 dateCount = TestTableRepository.Count(where);//.SetCacheTimeOut(10) } #endregion var list = TestTableRepository.Query(where, d => d.CreateTime, "desc", null, param._PageSize, param._PageIndex); return(new BaseResult(true, list, "", dateCount)); }
/// <summary> /// 获取数据。此数据会持续增长,所以不建议一次性缓存。建议单个Model实体缓存。 /// </summary> public BaseResult GetUser(TestTableParam param) { var where = new Where <TestTable1>(); #region 模糊搜索条件 if (!string.IsNullOrWhiteSpace(param.SearchName)) { where.And(d => !d.Name.Equals(param.SearchName)); } if (!string.IsNullOrWhiteSpace(param.SearchIDNumber)) { where.And(d => d.IDNumber.Like(param.SearchIDNumber)); } if (!string.IsNullOrWhiteSpace(param.SearchMobilePhone)) { where.And(d => d.MobilePhone.Like(param.SearchMobilePhone)); } #endregion #region 是否分页 var dateCount = 0; if (param._PageIndex != null && param._PageSize != null) { //取总数,以计算共多少页。自行考虑将总数缓存。 dateCount = TestTableRepository.Count(where);//.SetCacheTimeOut(10) } #endregion var list = TestTableRepository.Query(where, d => d.CreateTime, "desc", null, param._PageSize, param._PageIndex); //list[0].Id = Guid.NewGuid(); //list[0].AttachAll(); //var a = list[0].GetModifyFields(); //var b = list[1].GetModifyFields(); //list[0].Id = Guid.NewGuid(); //var aaaa = TestTableRepository.Insert(list[0]); #region 测试事务 var trans = Db.Context.BeginTransaction(); var mmmm = new TestTable1(); try { trans.Delete(new List <TestTable1>()); Db.Context.Delete(trans, new List <TestTable1>()); trans.Update(mmmm); throw new Exception("xxxxxxxx"); trans.Commit(); } catch (Exception) { trans.Rollback(); } finally { trans.Close(); } #endregion //var aaaaaa = GetAaa(); Aaa(new List <TestTable1>()); Aaa(trans, new List <TestTable1>()); //Aaa(aaaaaa); return(new BaseResult(true, list, "", dateCount)); }