EF4 LINQ - 在联接上添加过滤
如何在 LINQ 中将 FILTER CLAUSE 添加到 JOIN TABLE ....?
<块引用>AND t2.Public = 1 AND t2.Color = '蓝色'
SELECT t1.ID, t1.Name, (SELECT COUNT(*)
FROM tbl2 t2
WHERE t2.ID = t1.ID
AND t2.Public = 1 AND t2.Color = 'Blue') AS MyCount
FROM tbl1 t1
WHERE t1.State = 'CA'
How do I add a FILTER CLAUSE to a JOIN TABLE ....in LINQ ?
AND t2.Public = 1 AND t2.Color = 'Blue'
SELECT t1.ID, t1.Name, (SELECT COUNT(*)
FROM tbl2 t2
WHERE t2.ID = t1.ID
AND t2.Public = 1 AND t2.Color = 'Blue') AS MyCount
FROM tbl1 t1
WHERE t1.State = 'CA'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它应该看起来像这样。
这就是我在不了解上下文中实体的名称、它们之间的关系以及它们的标量值的类型的情况下可以提供的所有帮助。
It should look something like this.
That's about all the help I can give without knowing more about the names of the entities in your context, their relationships to each other, and the types of their scalar values.
如果您的实体之间没有导航属性,请使用:
如果它们具有导航属性,请使用 @StriplingWarrior 提供的解决方案
If your entities don't have navigation property between them use:
If they have navigation properties use solution provided by @StriplingWarrior