我有一个自动生成的dbml文件。我想在代码(VB.Net)中获取其中一个属性的关联值。这是如何实现的?
基本上,在我的vb.Net代码中,我希望以某种方式知道(在下面的示例中) LookupDocumentStatus.IsForeignKey和LookupDocumentStatus.ThisKey的值。
有没有简单的方法来获得这个值?
_ Public Property LookupDocumentStatus() As LookupDocumentStatus Get Return Me._LookupDocumentStatus.Entity End Get Set
发布于 2009-05-20 00:23:46
从http://blog.csdn.net/greatbag/archive/2009/02/12/3881235.aspx的大量研究中回答了我自己的问题
简单地说,这就是我所做的(当然,需要更多的代码来“做”我需要做的事情,但是,这里是基本格式)
Dim infos As PropertyInfo() = MyObject.GetType().GetProperties()
For Each pi As PropertyInfo In infos
Dim isAssociation As Boolean = False
For Each obj As Object In pi.GetCustomAttributes(True)
If obj.[GetType]() Is GetType(System.Data.Linq.Mapping.AssociationAttribute) Then
'Do some code here
Exit For
End If
Nexthttps://stackoverflow.com/questions/885433
复制相似问题