public BsTableDataSource <ADCDInfo> GET(NoVGetAdcdInfoForCounty request) { return(NoVerifyZZTXManager.GetADCDInfoForCounty(request)); }
public BsTableDataSource <ADCDInfo> GetADCDInfoForCounty(NoVGetAdcdInfoForCounty request) { using (var db = DbFactory.Open()) { var builder = db.From <ADCDInfo>(); switch (request.levle) { case 0: //全部 break; case 1: //省 builder.Where(x => x.adcd == "330000000000000"); break; case 2: //市 switch (RowID) { case 2: builder.Where("adcd ='" + adcd + "'"); //x => x.adcd != "330000000000000" && x.adcd.EndsWith("00")); break; case 5: builder.Where( "adcd like '33__00000000000' and adcd !='330000000000000'"); //x => x.adcd != "330000000000000" && x.adcd.EndsWith("00")); break; } //builder.And("len(adcd)=6"); break; case 3: //县(区) // builder.Where("adcd like '33____000000000' and adcd not like '33__00000000000'"); builder.Where(x => x.adcd == request.adcd); //builder.Where(x => x.adcd != "330000"&&!x.adcd.EndsWith("00")); //builder.And("len(adcd)=6"); // if (!string.IsNullOrEmpty(request.adcd) && request.adcd.Length == 15 && request.adcd.IndexOf("000000000") > 0) // builder.And("adcd like '" + request.adcd.Substring(0, 4) + "__000000000' and adcd !='" + request.adcd + "'"); break; case 4: //镇街 builder.Where("adcd like '%000000' and adcd not like '%000000000'"); //builder.Where(x => x.adcd.EndsWith("000000")); if (!string.IsNullOrEmpty(request.adcd)) { builder.And(x => x.adcd.StartsWith(request.adcd.Substring(0, 6)) && x.adcd != request.adcd); } break; case 5: //行政村 builder.Where(x => !x.adcd.EndsWith("000000") && x.adcd.EndsWith("000")); builder.And("len(adcd)=15"); if (!string.IsNullOrEmpty(request.adcd)) { builder.And(x => x.adcd == request.adcd); } else { builder.And(x => x.adcd.Contains(adcd.Substring(0, 9))); } break; case 51: //行政村1 builder.Where(x => x.adcd.Contains(request.adcd.Substring(0, 9)) && x.adcd.Substring(10, 3) != "000"); break; //case 6://自然村 // builder.Where(x => x.adcd.Length == 15 && x.adcd.Substring(12, 3) != "000"); // break; } if (!string.IsNullOrEmpty(request.adnm)) { builder.And(x => x.adnm.Contains(request.adnm)); } var count = db.Count(builder); var rows = request.PageSize == 0 ? 10 : request.PageSize; var skip = request.PageIndex == 0 ? 0 : request.PageIndex * rows; builder.Limit(skip, rows); builder.OrderBy(x => x.adcd); var list = db.Select(builder); return(new BsTableDataSource <ADCDInfo>() { total = count, rows = list }); } }