Linq to 实体查询不起作用
我有以下查询:
if (entities.User.Count(u => u.Id == ownerUserId && u.GroupId == null) == 0)
我想检查 Id == OwnerUserId 的 User 是否有其 GroupId == null,但它不起作用。
表:
User
----------------------------------------
Id | PK Not Null
GroupId | FK to Group Table. CAN BE NULL.
...
我想检查 Id == OwnerId
的用户是否有 GroupId == null
你知道为什么吗?
I have the following query:
if (entities.User.Count(u => u.Id == ownerUserId && u.GroupId == null) == 0)
I want to check if User with Id == ownerUserId has its GroupId == null, but it doesn't work.
Table:
User
----------------------------------------
Id | PK Not Null
GroupId | FK to Group Table. CAN BE NULL.
...
I want to check if User with Id == ownerId
has GroupId == null
Do you know why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望 if 条件在您提到的情况下为 true,则需要检查是否大于 0,而不是等于 0。
If you want the if condition to be true in the case you mentioned, you would need to check for greater than 0, rather than equal to 0.