【发布时间】:2011-12-29 18:45:49
【问题描述】:
我需要使用“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);
【问题讨论】:
标签: sql-server-2005 entity-framework c#-4.0 linq-to-entities