1

我正在尝试在 vb.net Linq 中转换此语句:

Dim exchangeTradingCapacity = (
From ts In db_context.TRADE_SUMMARies _
Join el In db_context.EXECUTION_LISTs On ts.TRADE_ID Equals el.TRADE_ID _
                                     And ts.TRADE_PART_INDEX Equals el.TRADE_PART_INDEX _
                                     And ts.VERSION Equals el.TRADE_VERSION _
Join oe In db_context.ORDER_EXECUTIONs On oe.EXECUTION_ID Equals ts.CONTRIBUTOR_REF _
Where rootOrdersToInclude.Distinct.Contains(el.ROOT_ORDER_ID) _
  And el.TRADE_VERSION = (From el1 In db_context.EXECUTION_LISTs _
                          Where el1.TRADE_ID = el.TRADE_ID _
                            And el1.TRADE_PART_INDEX = el.TRADE_PART_INDEX _
                            And el1.ROOT_ORDER_ID = el.ROOT_ORDER_ID _
                          Select el1.TRADE_VERSION).Max() _
Group oe By Key = oe.EXCHANGE_TRADING_CAPACITY Into Group _
Select Key
).ToList

到目前为止,我尝试将其转换为 c# 没有成功:

var exchangeTradingCapacity =
(from ts in dbContext.TRADE_SUMMARies
 join e1 in dbContext.EXECUTION_LISTs on
                    new
                    {
                        ts.TRADE_ID,
                        ts.TRADE_PART_INDEX,
                        ts.VERSION
                    }
                    equals
                    new
                    {
                        e1.TRADE_ID,
                        e1.TRADE_PART_INDEX,
                        VERSION = e1.TRADE_VERSION
                    }
join oe in dbContext.ORDER_EXECUTIONs on ts.CONTRIBUTOR_REF equals oe.EXECUTION_ID
where rootOrdersToInclude.Distinct().Contains(e1.ROOT_ORDER_ID) &&
      e1.TRADE_VERSION == (from el1 in dbContext.EXECUTION_LISTs
                           where el1.TRADE_ID == el.TRADE_ID &&
                                 el1.TRADE_PART_INDEX == el.TRADE_PART_INDEX &&
                                 el1.ROOT_ORDER_ID == el.ROOT_ORDER_ID
                           select el1.TRADE_VERSION).Max()
group oe by oe.EXCHANGE_TRADING_CAPACITY into theKey
select theKey
).ToList();

似乎由于某种原因,“el”在子查询中超出了范围。有人可以指出我的方式错误吗?看来这应该可行。

4

1 回答 1

1

您没有别名 el(字母 L),只有别名 e1(数字 1)。

于 2013-10-22T18:22:34.330 回答