Friday, June 08, 2007 3:52 PM
Geoff
XSD xs:integer to VB.NET type mapping foolishness
I don't know if you should blame Microsoft, or the... people... who did the XSD spec. Anyway, according to the XSD spec, the integer type is a numeric value with no upper or lower bounds. .NET therefore struggles to find a way to map it to any value, as deciding on whether it should be an Int16, Int32 or Int64 is based entirely on the bounds of the number. You can kind of understand that.
"Well, what does it map to then?", I hear you both cry! (How are you anyway, mum?). If your next best guess would be a DateTime type, you wouldn't be far wrong! It actually maps to a String. So next time you're playing with XML serialisation of types for whatever reason, and you need to map to types from a schema, make sure you declare all integer types with a .NET string type!
PS. Oh, and for validation's sake, it maps to a decimal...
Filed Under:
.NET Development,
XML