我有一个视图模型,它代表所有可用于搜索的字段。我想添加一些逻辑,能够识别搜索值是否都相同,并确定是否再次点击数据库进行查询。
我想我必须做类似的事情..
- 用户提交表单后,将表单值保存到某个临时字段。
- 在第二次提交时将临时值与表单值集合进行比较。
- 如果值相等,则在视图模型中设置属性 IsSameSearch = true
我也想使用 Post Redirect Get Pattern。因此,我的搜索视图除了将表单值发布到另一个处理和过滤数据的操作之外,什么都不做,然后使用 Ajax “获取”。
SearchViewModel 包含许多搜索参数。这是一个缩略版。
public bool UseAdvancedSearch { get; set; }
public bool isSameSearch { get; set; }
/// <summary>
/// Gets or sets the page.
/// </summary>
[HiddenInput]
[ScaffoldColumn(false)]
public int Page { get; set; }
[HiddenInput]
[ScaffoldColumn(false)]
public string SortOption { get; set; }
/// <summary>
/// Gets or sets the address keywords.
/// </summary>
[Display(Name="Address")]
public string AddressKeywords { get; set; }
/// <summary>
/// Gets or sets the census.
/// </summary>
public string Census { get; set; }
/// <summary>
/// Gets or sets the lot block sub.
/// </summary>
public string LotBlockSub { get; set; }
/// <summary>
/// Gets or sets the owner keywords.
/// </summary>
[Display(Name="Owner")]
public string OwnerKeywords { get; set; }
/// <summary>
/// Gets or sets the section township range.
/// </summary>
public string SectionTownshipRange { get; set; }
/// <summary>
/// Gets or sets the strap.
/// </summary>
///
[Display(Name="Account Number/Parcel ID")]
public string Strap { get; set; }
/// <summary>
/// Gets or sets the subdivision.
/// </summary>
public string Subdivision { get; set; }
/// <summary>
/// Gets or sets the use code.
/// </summary>
[Display(Name = "Use Code")]
public string UseCode { get; set; }
/// <summary>
/// Gets or sets the zip code.
/// </summary>
[Display(Name="Zip Code")]
public string ZipCode { get; set; }