将此 SQL 语句转换为 LINQ
我对 linq 很陌生,在 LINQ 中高效编写此查询时遇到一些困难。
SELECT ID, UniqueID, RouteHeaderID, RouteObjectState, OriginalRouteUniqueID
FROM dbo.MeterReadingOrderERPRouteCreateResponses
WHERE (ID NOT IN (SELECT MeterReadingOrderERPRouteCreateResponseID
FROM dbo.Tasks
WHERE (TaskType = 'MeterReading')))
有什么帮助吗?我尝试过以下解决方案:你会如何做使用 LINQ 进行“不在”查询? 但出现以下错误:无法创建“TaskManager.Models.Task”类型的常量值。此上下文中仅支持原始类型(“例如 Int32、String 和 Guid”)。
i am quite new to linq and i am having some difficulties writing this query efficiently in LINQ.
SELECT ID, UniqueID, RouteHeaderID, RouteObjectState, OriginalRouteUniqueID
FROM dbo.MeterReadingOrderERPRouteCreateResponses
WHERE (ID NOT IN (SELECT MeterReadingOrderERPRouteCreateResponseID
FROM dbo.Tasks
WHERE (TaskType = 'MeterReading')))
any help please? I have tried this solution from: How would you do a "not in" query with LINQ? but was getting the following error: Unable to create a constant value of type 'TaskManager.Models.Task'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是在我的脑海里做这件事,但也许这个?
Just doing this off the top of my head, but maybe this?