public ActionResult SearchCustomerAddress(AddressSearchCondition condition) { var addresslist = BS.SearchCustomerAddress(condition); var result = new JsonNetResult() { Data = addresslist, MaxJsonLength = int.MaxValue }; result.Settings.DateFormatString = "yyyy-MM-dd"; return(result); }
public List <ZZAddressInfo> SearchCustomerAddress(AddressSearchCondition condition) { using (var db = GetDbContext()) { var customerPred = PredicateBuilder.New <ZY_Customer>(true); if (!string.IsNullOrEmpty(condition.CustomerName)) { customerPred = customerPred.And(x => x.UserName.Contains(condition.CustomerName)); } var tmp = from a in db.ZZ_Address join c in db.ZY_Customer.AsExpandable().Where(customerPred) on a.CustomerId equals c.OpenId select new ZZAddressInfo() { CustomerName = c.UserName, CreatedDate = a.CreatedTime, Address = a.Province + " " + a.City + " " + a.Town + " " + a.AddressLine1, ContactName = a.ContactName, Phone = a.Phone, IsDeleted = a.IsDeleted, AddressId = a.AddressId }; return(tmp.OrderBy(x => x.CustomerName).ThenByDescending(x => x.CreatedDate).ToList()); } }