public BsTableDataSource <VillageTransferPersonViewModel> Get(NoVerifyGetVillageTransferPerson request) { return(NoVerifyVillageTransferPersonManager.NoVerifyGetVillageTransferPerson(request)); }
public BsTableDataSource <VillageTransferPersonViewModel> NoVerifyGetVillageTransferPerson(NoVerifyGetVillageTransferPerson request) { using (var db = DbFactory.Open()) { //if (string.IsNullOrEmpty(adcd)) // throw new Exception("请重新登录"); //if (request.year==null) // throw new Exception("年度异常"); var builder = db.From <ADCDInfo>(); builder.LeftJoin <ADCDInfo, VillageTransferPerson>((x, y) => x.adcd == y.adcd); builder.LeftJoin <VillageTransferPerson, DangerZone>((x, y) => x.DangerZoneType == y.DangerZoneName); if (!string.IsNullOrEmpty(request.adcd)) { builder.And(x => x.adcd == request.adcd); } if (request.year != null) { builder.And <VillageTransferPerson>(y => y.Year == request.year); } if (request.nums != null && request.nums > 1) { builder.And <VillageTransferPerson>(y => y.AuditNums == request.nums); } builder.Select("VillageTransferPerson.*,ADCDInfo.adnm,DangerZone.Id as DId"); var count = db.Count(builder); if (!string.IsNullOrEmpty(request.Sort) && !string.IsNullOrEmpty(request.Order) && request.Order == "asc") { builder.OrderBy(x => request.Sort); } else if (!string.IsNullOrEmpty(request.Sort) && !string.IsNullOrEmpty(request.Order) && request.Order == "desc") { builder.OrderByDescending(x => request.Sort); } else { builder.OrderByDescending(x => x.CreateTime); } var PageSize = request.PageSize == 0 ? 15 : request.PageSize; var PageIndex = request.PageIndex == 0 ? 0 : request.PageIndex * PageSize; builder.Limit(PageIndex, PageSize); var list = db.Select <VillageTransferPersonViewModel>(builder); return(new BsTableDataSource <VillageTransferPersonViewModel>() { rows = list, total = count }); } }