gpt4 book ai didi

entity-framework - 在 Entity Framework 中向实体添加或条件

转载 作者:行者123 更新时间:2023-12-04 07:25:51 24 4
gpt4 key购买 nike

您可以在 Entity Framework 中为实体添加“或”条件吗?例如类似的东西:

Property1 == (1 or 2 or 3)



我在输入“1 || 2 || 3”或“1,2,3”或“1 or 2 or 3”的值时得到的消息返回此消息:

condition is not compatible with the type of the member

最佳答案

你需要做:

var results = entityCollection.Where(entity => entity.Property1 == 1 || entity.Property1 == 2 || entity.Property1 == 3);

关于entity-framework - 在 Entity Framework 中向实体添加或条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2568816/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com