实体 Famework 中的 where in 子句
我需要编写一个带有“where in”子句的查询。我正在使用实体框架 4。
我的 sql 查询是:
select ITEMNMBR, locncode, qtyonhnd, atyalloc
from dbo.iv00102
where ITEMNMBR IN (
SELECT cmptitnm
from dbo.bm00111
where itemnmbr == bomItem)
AND LOCNCODE = 'MEMPHIS'
需要这样的查询:
public static Func<DBEntities, string, IQueryable<IV00102>> compiledMemphisQuery =
CompiledQuery.Compile((DBEntities ctx, string bomNumber) =>
from items in ctx.IV00102
where items.ITEMNMBR in (
from orders in ctx.bm00111
where orders.itemnmbr == bomItem
select orders.cmpitnm)
and items.locncode == "Memphis"
select items);
I have a requirment to write a query with "where in" clause. I am using entity framework 4.
My sql query is:
select ITEMNMBR, locncode, qtyonhnd, atyalloc
from dbo.iv00102
where ITEMNMBR IN (
SELECT cmptitnm
from dbo.bm00111
where itemnmbr == bomItem)
AND LOCNCODE = 'MEMPHIS'
Need a query somthing like this:
public static Func<DBEntities, string, IQueryable<IV00102>> compiledMemphisQuery =
CompiledQuery.Compile((DBEntities ctx, string bomNumber) =>
from items in ctx.IV00102
where items.ITEMNMBR in (
from orders in ctx.bm00111
where orders.itemnmbr == bomItem
select orders.cmpitnm)
and items.locncode == "Memphis"
select items);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用查询的 Contains 扩展方法。它应该有效:
Use the Contains extension method of the query. It should work: