Like运算符或使用通配符LINQ到实体 [英] Like operator or using wildcards in LINQ to Entities

查看:146
本文介绍了Like运算符或使用通配符LINQ到实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用LINQ 2实体。
以下的问题:

I'm using LINQ 2 Entities. Following is the problem:

string str = '%test%.doc%' 
.Contains(str) // converts this into LIKE '%~%test~%.doc~%%'

预期转换:LIKE'%测试%的.doc%

Expected Conversion: LIKE '%test%.doc%'

如果这是LINQ 2 SQL,我可以用SqlMethods.Like正如有人在我刚才的问题回答了。但现在因为我使用L2E不L2S,我需要其他的解决方案。

If it was LINQ 2 SQL, I could have used SqlMethods.Like as somebody answered it in my previous question. But now as I'm using L2E not L2S, I need other solution.

推荐答案

您可以尝试使用的这篇文章,这里笔者介绍了如何构建一个LIKE声明与LINQ通配符实体。

You can try use this article, where author describes how to build a LIKE statement with wildcard characters in LINQ to Entities.

这篇关于Like运算符或使用通配符LINQ到实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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