如何在c#中过滤记录 [英] how to filter records in c#

查看:90
本文介绍了如何在c#中过滤记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在建立一个购物车网站,我希望按产品名称和价格过滤记录。所以,请你帮忙,因为我对此一无所知。

Hi,
I am making a shopping cart website in which i want to filter records by products name and price. so can you please help me , as i do not have any idea about it.

推荐答案

如果您正在使用查询,请在查询级别过滤数据。这将是最优化的过滤器,因为您将通过线路发送较少的数据。
If you are using queries, filter data at the query level. This would be the most optimized filter as you would send less data over the wire.


有两种方法



1.每次使用ajax更改搜索文本框时对db进行查询,并使用 (例如'%searchstring%'
在db中应用过滤器/>






2.使用EF / SP / DataReader获取UI /服务/业务层的所有数据。 ..并使用 LINQ 中的 .Contains 子句过滤数据
There are two approaches

1. Make query to db each time the search text box changes using ajax, and apply the filter in db using like '%searchstring%'

OR

2. Get all data to UI/Service/Business layer using EF/SP/DataReader ... and filter data using .Contains clause in LINQ


当你说记录时,我在这里假设数据库表记录选择。你检查了你的SQL查询(Where子句,连接等)??
When you say records, I am assuming Database table record selection here. Have you checked your SQL Queries (Where clause, Joins etc)??


这篇关于如何在c#中过滤记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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