这是我的问题。我有一个SearchViewModel
具有大量搜索条件的值,这些值根本不适合 URL。我目前正在使用Troy Goode's Html.PagedListPager
,但它旨在用于Url.Action()
发送 URL 中的参数。这是一个例子。我不认为客户端过滤是一种选择,因为我会有很多记录。
@Html.PagedListPager(
(IPagedList)@Model.SearchResults,
page => Url.Action("Results",
new {
YearBuiltFrom = Model.YearBuiltFrom,
}
))
}
如果您只有一个或两个简单参数,这是一个很好的解决方案。
搜索视图模型
public class SearchViewModel
{
public int? page { get; set; }
public int? size { get; set; }
[IgnoreDataMember]
public IPagedList<Property> SearchResults { get; set; }
public string[] Locations { get; set; }
[IgnoreDataMember]
public MultiSelectList LocationOptions { get; set; }
public string[] ZipCodes { get; set; }
[IgnoreDataMember]
public MultiSelectList ZipCodeOptions { get; set; }
[Display(Name="Year Built")]
public int? YearBuiltFrom { get; set; }
[Display(Name = "Year Built")]
public int? YearBuiltTo { get; set; }
public int? SqftFrom { get; set; }
public int? SqftTo { get; set; }
public string Bedrooms { get; set; }
public string Bathrooms { get; set; }
[DataType(DataType.Date)]
public DateTime? SalesFrom { get; set; }
[DataType(DataType.Date)]
public DateTime? SalesTo { get; set; }
public int? SaleAmountFrom { get; set; }
public int? SaleAmountTo { get; set; }
public int? LandAreaFrom { get; set; }
public int? LandAreaTo { get; set; }
public string[] Waterfront { get; set; }
[IgnoreDataMember]
public MultiSelectList WaterfrontOptions { get; set; }
//TODO: Implement LandAreaType as a search parameter
//public string LandAreaType { get; set; }
public Boolean? IsVacant { get; set; }
public string[] PropertyFeatures { get; set; }
[IgnoreDataMember]
public MultiSelectList PropertyFeatureOptions { get; set; }
}