进阶搜寻页面 [英] Advanced search page

查看:87
本文介绍了进阶搜寻页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我已经阅读了一些有关linq to sql以及在linq中使用存储过程的教程.实际上,它们中的许多仅处理一个参数,而仅对一个表进行搜索.现在,我想使用linq数据模型在ASP.NET中创建一个高级搜索页面,并在连接的表上进行4到6个参数(文本框,下拉列表)的高级搜索.请帮助我如何做到这一点,否则某些示例(应用程序)可能会很有帮助.

最好的问候.

Hello

I have read some tutorial about linq to sql and working with stored procedure in linq. Actually a lot of them work on just one parameter and searching on just one table. Now I like to make an advanced search page in ASP.NET with linq data model and advance searching on 4 to 6 parameter (text box, drop down list,) on joined tables. Please help how I can do that, or some sample (application) can be very helpful.

Best regards.

推荐答案

您应该通过将它们尽可能多地连接到数据库中(在数据库中),使搜索表成为一个单一的 view . br/> 将视图带入数据层和业务层后,您可以非常轻松地通过LINQ表达式应用条件.
只需使用AND运算符将搜索项分开.
因此,当用户点击搜索按钮时,您应该执行以下操作:

... MySearchView.Where(i => i.Name == NameCriteria.Text& i.Country == DropDownList.SelectedVaule&& ...);

或者如果您的数据层支持导航,请执行以下操作:

... Country.Where(i => i.Country == DropDownList.SelectedVaule).Students.Where(i => i.Name == NameCriteria.Text)...

(请注意每个步骤中的空结果)

并将结果重定向到网格等.

希望它能为您提供一些线索.
You should make your search tables into a one single view by joining them as much as possible(in Database)
After bringing your view into data layer and business layer you can apply the criteria by LINQ expressions very easily.
Just separate search items by AND operators.
So when user clicks on search button you should do something like this :

... MySearchView.Where(i=> i.Name == NameCriteria.Text && i.Country == DropDownList.SelectedVaule && ... );

or if your Data layer supports navigation do something like this :

... Country.Where(i => i.Country == DropDownList.SelectedVaule).Students.Where(i=> i.Name == NameCriteria.Text ) ...

(take care of null result in each step)

and redirect the results to a grid or something like that.

Hope it gives you some clues.


这篇关于进阶搜寻页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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