我正在尝试检索包含Britney Spears"的字符串列表,这就是我使用的
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
这很好用,但是如果我想选择标题为Britney Jean Spears"、Britney 'Sexy' Spears"就行不通了,所以我的问题是如何在中间插入通配符 '%'Britney Spears 在进行 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.
问候,安迪.
您可以使用 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 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
C# ADO.NET:空值和 DbNull —— 有没有更高效的语法C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有没有更高效的语法?)
如何在c#中将空值设置为int?How to set null value to int in c#?(如何在c#中将空值设置为int?)
使用 Min 或 Max 时如何处理 LINQ 中的空值?How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 时如何处理 LINQ 中的空值?)
Asp.net System.Web.HttpContext.Current.Session 在 global.asaAsp.net System.Web.HttpContext.Current.Session null in global.asax(Asp.net System.Web.HttpContext.Current.Session 在 global.asax 中为 null)
捕获的异常本身为空!Caught exception is null itself !(捕获的异常本身为空!)
为什么连接空字符串有效但调用“null.ToString()&Why is it Valid to Concatenate Null Strings but not to Call quot;null.ToString()quot;?(为什么连接空字符串有效但调用“null.ToString()无效