LINQ to SQL and get association values from dbml file
I have a dbml file that has been autogenerated. I want, in code (VB.Net), to get the association values for one of the properties. How is this achieved?
Basically, in my vb.Net code, I would like to somehow find out (in the following example) the value of LookupDocumentStatus.IsForeignKey and LookupDocumentStatus.ThisKey.
Is there an easy way to get this value?
_ Public Property LookupDocumentStatus () As LookupDocumentStatus Get Return Me._LookupDocumentStatus.Entity End Get Set
0
a source to share
1 answer
Answered my own question from a lot of research from http://blog.csdn.net/greatbag/archive/2009/02/12/3881235.aspx
In simplicity, this is what I did (of course, more code to "do" what I need, but here it is in basic format)
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
Next
0
a source to share