StrataFrame Forum

Generic Nullable Gives Compiler Error

http://forum.strataframe.net/Topic5539.aspx

By Richard Keller - 1/2/2007

I used the Customize Property of the Business Object Mapper to try and set the properties of a Null Field.   Here is the error that I get:

Error 2 Type argument 'String' does not satisfy the 'Structure' constraint for type parameter 'T' 

By Richard Keller - 1/2/2007

I think I figured it out.   The database column was a string value so that the Generic Nullable is not needed and the application "should" be able to handle because you can set the String to Null without the NUllable Call. 

Thanks,

Richard

By StrataFrame Team - 1/3/2007

That's almost correct... the Use Nullable Generic option can only be used with value types that are not nullable (structures, integers, doubles, datetimes, etc.).  The System.String data type is a reference type, but it still cannot be cast to DBNull.Value.  So, instead of using the Nullable Generic option, you'll most likely need to use the "Return Alternate On Null" option, which returns an alternate value if a Null value is encountered.  So, the replacement value would most likely be Nothing (or null for C#).