使用(LINQ)将DataClass的所有列名称获取到字符串数组中

问题描述 投票:0回答:1

我想从我的数据上下文(名为dc)中获取我的数据类的所有表头。enter image description here

我尝试了很多不同的方法:enter image description hereenter image description hereenter image description here

依此类推。

我经历了许多不同的(stackoverflow)页面,但是我陷入了困境。

感谢您的任何帮助。

vb.net reflection linq-to-sql
1个回答
0
投票

通过以下代码解决:所以我的GetType DataContext应该是ProductionDataContext,因为我将其重命名了。 VS给的错误让我感到困惑,并且不再看了。

Dim dc As New ProductionDataContext
Dim columnNames = dc.Mapping.MappingSource.GetModel(GetType(ProductionDataContext)).GetMetaType(GetType(tblInterventies)).DataMembers
© www.soinside.com 2019 - 2024. All rights reserved.