Generic Nullable Gives Compiler Error


Author
Message
Richard Keller
Richard Keller
StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)
Group: Forum Members
Posts: 84, Visits: 324
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' 

Richard Keller
Richard Keller
StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)
Group: Forum Members
Posts: 84, Visits: 324
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

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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#).
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search