vb.net 2005 reflection question

Mercypoint

Weaksauce
Joined
Oct 22, 2005
Messages
74
Hi,
I'm trying to "force feed" my class from the database. I have a class with properties that is exactly named as a table column names expect for in the class, it is camel cased and in the database, it is all caps.
My problem is that I can't get the Bindingflags.IgnoreCase to work for me.

Code:
Dim propInfo as PropertyInfo
Dim columnName as String
For i as Integer = 0 To datatable.columns.Count -1
  columnName = datatable.columns.item(i).columnName
  propInfo = oType.GetProperty(columnName, BindingFlags.IgnoreCase)

propInfo will always return a Nothing because the case do not match. Am I missing something?

Thanks
 
When you specify BindingFlags, you need to specify the default BindingFlags as well. Something like this would be what you'd need

Code:
oType.GetProperty(columnName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty);

Note, that's c# syntax above, I'm not sure what the bitwise or operator is in VB.NET.
 
Back
Top