用于短语的 LINQ2SQL LIKE 命令

LINQ2SQL LIKE Command for Phrase(用于短语的 LINQ2SQL LIKE 命令)
本文介绍了用于短语的 LINQ2SQL LIKE 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试检索包含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 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
How to store delegates in a List(如何将代表存储在列表中)
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
CreateDelegate with unknown types(具有未知类型的 CreateDelegate)
Does Funclt;Tgt;.BeginInvoke use the ThreadPool?(Funclt;Tgt;.BeginInvoke 使用线程池吗?)
How to create a delegate to an instance method with a null target?(如何为具有空目标的实例方法创建委托?)