Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的网站上实现一个搜索框,以从数据库中的多个列中搜索文本。我正在使用实体框架。性能对我来说是一个大问题。所以搜索一定要快。我以前没有做过这样的事情。所以有人可以给我一些想法,我可以从哪里开始。
干杯
您可以使用 LINQ 查询轻松完成此操作,如下所示:
var matchingProducts = context.Products.Where(p => p.Name.Contains("SearchValue") || p.Description.Contains("SearchValue"));
我通常认为生成的 SQL 查询的性能是可以接受的。