问题描述
我想构造一个LINQ查询针对基于一个LIKE条件选择行的EF环境中使用。
据我了解,你可以使用。载获得这一行为()
。但是,就像我想包括含有数范围:
I would like to construct a LINQ query for use against an EF context that selected rows based on a LIKE condition.As I understand you can get this behaviour using .Contains()
. However, the LIKE I would like to include contains a number range:
LIKE 'LN[0-9]%'
例如...
我怎么会去在一个简单的查询复制这种行为?
How would I go about replicating this behaviour in a simple query?
谢谢,
推荐答案
目前你无法在LINQ直接使用等。 ü可以使用 StartsWith
,包含
或的endsWith
被翻译喜欢。其他的解决方案是使用',其中'像这样'字符串'在此改变:
凡(像这样'LN [0-9]%')
Currently u can't use like in LINQ directly. U can use StartsWith
, Contains
or EndsWith
that are translated to LIKE. Other solution is using 'Where' overide with 'string' like this: Where("something LIKE 'LN[0-9]%'")
这篇关于实体框架:如何前preSS包含LIKE语句[0-9]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!