本文介绍了LINQ2SQL LIKE命令词组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检索字符串列表,其中包含布兰妮斯皮尔斯了,这是我用

I am trying to retrieve a list of string where it contains "Britney Spears", and this is what I use

from p in Objects
where p.Title.Contains("Britney Spears")
select p

这工作正常,但如果我要选择的标题是劲舞布兰妮·斯皮尔斯,布兰妮性感布兰妮这是行不通的,所以我的问题是我怎么插入的通配符'%'布兰妮斯皮尔斯而在进行LINQ2SQL搜索?谢谢你。

That works fine, but if I want to select title which is "Britney Jean Spears", "Britney 'Sexy' Spears" it doesn't work, so my question is how do I insert a wildcard '%' in between Britney Spears while conducting a LINQ2SQL search? Thanks.

问候,安迪。

推荐答案

您可以使用<$c$c>SqlMethods.Like方法用于此目的。

You can use the SqlMethods.Like method for this purpose.

from p in Objects
where SqlMethods.Like(p.Title, "Britney% Spears")
select p

这篇关于LINQ2SQL LIKE命令词组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-18 01:27