【发布时间】:2009-03-04 04:43:19
【问题描述】:
我有以下 Linq 语句:
(from order in Orders.AsEnumerable()
join component in Components.AsEnumerable()
on order.ORDER_ID equals component.ORDER_ID
join detail in Detailss.AsEnumerable()
on component.RESULT_ID equals detail.RESULT_ID
where orderRestrict.ORDER_MNEMONIC == "MyOrderText"
select new
{
Mnemonic = detail.TEST_MNEMONIC,
OrderID = component.ORDER_ID,
SeqNumber = component.SEQ_NUM
}).ToList()
我希望这会发出以下查询:
select *
from Orders ord (NoLock)
join Component comp (NoLock)
on ord .ORDER_ID = comp.ORDER_ID
join Details detail (NoLock)
on comp.RESULT_TEST_NUM = detail .RESULT_TEST_NUM
where res.ORDER_MNEMONIC = 'MyOrderText'
但我得到 3 个单独的查询,它们从表中选择所有行。我猜 Linq 正在过滤这些值,因为我最终得到了正确的值。
问题在于它需要 WAY WAY 太长时间,因为它正在从所有三个表中拉下所有行。
有什么办法可以解决这个问题吗?
【问题讨论】:
标签: linq entity-framework