实施精细搜索-ASP.NET MVC [英] Implementing refined search - ASP.NET MVC

查看:73
本文介绍了实施精细搜索-ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ASP.NET MVC应用程序中,我有一个视图,该视图显示系统中的产品列表.我想为用户实现一个选项,通过选择参数来筛选产品列表,这与在 www上进行的操作类似. codeplex.com .我想知道您将如何以最有效,最简单的方式进行此操作?任何指向教程或指南的链接都将受到赞赏.

In my ASP.NET MVC application I have a view that displays a list of Products in the system. I would like to implement an option for users to filter the list of Products by selecting parametes, similar to the way it's done on www.codeplex.com. I would like to know how you would go about doing this in the most efficient and simple way? Any links to tutorials or guides are appreciated.

推荐答案

基本上,对于这种类型的搜索(服务器端),您需要:

Basically, for a search of this type (server-side), you need:

  1. <form>中的字段,供用户填写以执行搜索请求.
  2. 将表单字段发布到控制器方法的按钮
  3. Linq查询的存储库,它将返回正确的记录.
  4. 存储库中的一种方法,该方法接受您捕获的参数,并执行linq查询以返回过滤后的结果,并使用Where子句过滤返回的记录.
  5. 查询结果将返回到视图以供显示.
  1. Fields in a <form> for the user to fill out to perform the search request.
  2. A button to post the form fields to your controller method
  3. A repository for the Linq queries that will return the proper records.
  4. A Method in the repository that accepts the parameters you have captured, and executes a linq query returning your filtered result, using Where clauses to filter the returned records.
  5. The result of the query gets returned to the view for display.

如果您需要动态功能(即用户可以省略一个或多个参数,并且需要在运行时在Linq查询中灵活指定这些参数),请查看

If you need dynamic capabilities (i.e. the user may omit one or more parameters, and you need the flexibility to specify those parameters in the Linq query at runtime), then have a look at Dynamic Linq.

这篇关于实施精细搜索-ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆