I had limited time, but I wrote a function that you may be able to use
to get the DB field name from the property's attribute.
That is assuming it is the only attribute on the property.
Public Shared Function GetPropertyFirstAttributeValue(ByVal
ObjectPropertyIsIn As Object, ByVal PropertyName As String) As String
' Get the type or class for the object that the property
is in.
' This hooks us into .net reflection functionality.
Dim typClassInfo As Type = ObjectPropertyIsIn.GetType()
' Get the property we want to get the attribute value for.
Dim objPropertyReflectionInfo As PropertyInfo =
typClassInfo.GetProperty(PropertyName)
' Get the propertys first attribute value
Dim strFirstAttributeValue As String =
objPropertyReflectionInfo.GetCustomAttributesData(0).ConstructorArguments(0).Value.ToString()
' Return the propertys first attribute value
Return strFirstAttributeValue
End Function
On Jun 15, 1:43 pm, Steve <[email protected]> wrote:
> I would like to create a function which I can pass in a custom object
> and receive a collection of SQLParameter objects. The class properties
> already have an attribute (specifying the DB field name) on each
> property for binding to a DataReader. I would think this could be done
> with reflection. Can someone point me to an example?
>
> Thanks,
>
> Steve
--
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net