/// <summary> /// /// </summary> /// <param name="request"></param> /// <returns></returns> public BsTableDataSource <VillageViewModel> GetVillagePicAdcd(GetVillagePicAdcd request) { using (var db = DbFactory.Open()) { var year = DateTime.Now.Year; if (request.year != 0) { year = request.year; } var builder = db.From <ADCDInfo>(); builder.LeftJoin <ADCDInfo, VillagePic2>((x, y) => x.adcd == y.Adcd); builder.Where(x => x.adcd.StartsWith(adcd.Substring(0, 9)) && x.adcd != adcd); if (!string.IsNullOrEmpty(request.adnm)) { builder.And(x => x.adnm.Contains(request.adnm)); } if (!string.IsNullOrEmpty(request.adcd)) { builder.And(x => x.adcd == request.adcd); } builder.SelectDistinct(x => new { x.Id, x.adcd, x.adnm }); if (request.type == 0)//0:未上报,1:已上报 { builder.And <VillagePic2>(y => y.PicName == string.Empty || y.PicName == null); } else if (request.type == 1) { builder.And <VillagePic2>(y => y.PicName != "" && y.Year == year); } else if (request.type == 2) { } else { throw new Exception("上报状态不正确"); } var count = db.Select(builder).Count; 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.OrderBy(x => x.adcd); } var rows = request.PageSize == 0 ? 10 : request.PageSize; var skip = request.PageIndex == 0 ? 0 : (request.PageIndex - 1) * rows; builder.Limit(skip, rows); var list = db.Select <VillageViewModel>(builder); return(new BsTableDataSource <VillageViewModel>() { total = count, rows = list }); } }
public BsTableDataSource <VillageViewModel> Get(GetVillagePicAdcd request) { return(VillagePicManager.GetVillagePicAdcd(request)); }