1

我真正想要的是在 Scott Gu 的博客中将这两个表选择为匿名类型:这里但是,我会满足于这种创建的类型“ActiveLots” 我将两个表连接在一起,并希望能够引用每个表中的列在我的结果集中。

我似乎没有正确理解语法。

 Dim pi = From p In dc.Inventories Join i In dc.InventoryItems On p.InventoryItemID _
                     Equals i.InventoryItemID Where p.LotNumber <> "" _
                     Select New ActiveLots LotNumber = p.LotNumber, Quantity = p.Quantity, Item = i.Item, Uom = i.UnitofMeasure, Description = i.Description
4

1 回答 1

2

看看Daniel Moth 的博客条目。我怀疑你想要:

Dim pi = From p In dc.Inventories _
         Join i In dc.InventoryItems
              On p.InventoryItemID Equals i.InventoryItemID _
         Where p.LotNumber <> "" _
         Select New With { .LotNumber = p.LotNumber, .Quantity = p.Quantity, _
                           .Item = i.Item, .Uom = i.UnitofMeasure, _
                           .Description = i.Description }

那是使用匿名类型 - 要使用具体类型,您将使用New ActiveLots With { ...(其中ActiveLots必须有一个无参数构造函数)。

于 2009-05-28T09:55:44.080 回答