使用对象属性Vb.Net的Linq顺序

时间:2017-10-20 13:08:32

标签: vb.net linq

我在地图中有一个pointhape对象的数据表,我想通过Object.baseshape.label.y订购这个列表,这是一个double值。我怎么能用Linq做到这一点? 到目前为止我已实现此代码

Dim query As IEnumerable(Of DataRow) = From result In dataArray.AsEnumerable() Order By result.Field(Of Object)("MapShapes") Descending

但我想要这样的东西

Dim query As IEnumerable(Of DataRow) = From result In dataArray.AsEnumerable() Order By result.Field(Of Object)("MapShapes")..baseshape.label.y Descending 

1 个答案:

答案 0 :(得分:1)

你可以在Field(Of ...)中使用特定的对象类型,就像这样......

Dim query = From result In dataArray.AsEnumerable() Order By result.Field(Of MapSuite.BaseMapShape)("MapShapes").label.y Descending