【发布时间】:2014-05-16 19:57:18
【问题描述】:
我有以下简单的连接语句:
Dim result = (From PropertyDefinition In econtext.PropertyDefinitions
Join ProductDef In econtext.ProductPropertyValues
On PropertyDefinition.PropertyDefID Equals ProductDef.ProductPropDefID
Where ProductDef.ProductID = 1
Select ProductDef,
PropertyDefinition.PropertyDefName,
PropertyDefinition.PropertyDefName2,
PropertyDefinition.PropertyDefIIsDeleted).list()
如果我明确包含 ProductDef 下的所有列,它会起作用,并且结果出现在一个列表中,目前 ProductDef 的结果出现在一个单独的列表中:
我需要 ProductDef 中的所有内容和 PropertyDefinition 中的一些内容,但嵌套列表中不需要,
如何在不需要显式包含ProductDef的所有列的情况下获得一次性列表中的结果?
【问题讨论】:
-
像这样:
Select ProductDef.ProductPropValueID, ProductDef.ProductID, ProductDef.ProductPropDefID,etc而不仅仅是Select ProductDef -
@GertArnold,这里的问题不同,我没有对返回的数据进行自定义,我只有PropertyDefinition的两个属性和ProductDef的25个,写一个真的很痛苦代码中的一个。
-
我没有看到任何显着差异。你想做的事是做不到的。在 LINQ 中没有 SELECT * 的等价物。
标签: c# asp.net vb.net entity-framework linq-to-sql