Bla*_*ell 6 entity-framework entity-framework-4
你能在实体框架中为实体添加"或"条件吗?例如:
Property1 ==(1或2或3)
将值设置为"1 || 2 || 3"或"1,2,3"或"1或2或3"时收到的消息将返回以下消息:
Run Code Online (Sandbox Code Playgroud)condition is not compatible with the type of the member
Ree*_*sey 12
你需要这样做:
var results = entityCollection.Where(entity => entity.Property1 == 1 || entity.Property1 == 2 || entity.Property1 == 3);
Run Code Online (Sandbox Code Playgroud)
itc*_*chi 10
您还应该查看谓词构建器:http: //www.albahari.com/nutshell/predicatebuilder.aspx
它有点先进,但如果你必须动态连锁条件,这是你最好的选择.
foreach (string keyword in keywords)
{
string temp = keyword;
predicate = predicate.Or (p => p.Description.Contains (temp));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19016 次 |
| 最近记录: |