Question on Tutorial


Author
Message
Bo Harris
Bo Harris
StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)
Group: Forum Members
Posts: 5, Visits: 16
Working through the tutorial and got the CustomerMaintenance form up and running. However when I click on "New" an InvalidCastException is thrown.



Exception message states "Unable to cast object of type 'System.DBNull' to type 'System.String'." Offending line of code is in the 'get' accessor for the CustomerID field and reads - "[font=Courier New]return (System.String)this.CurrentRow["CustomerID"];[/font]".



I know I can put in some code in the get accessor to check for DbNull but was just wondering if there is a property or something that can be set to true so that the generated code will automatically account for null scenarios.
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (664 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
Have you looked at the NULL Value Option and NULL Replacement Value when you edit a field in the BO Mapper? Both of these typically allow you to account for NULLs however you prefer. You can set it to Use Nullable Generics (where it can), or to replace a NULL with a specific value (i.e. "" or String.Empty).

There are several options there, so you may want to take a look and see if any of them suit your fancy Smile.

Dustin Taylor
Dustin Taylor
StrataFrame Team Member (664 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
Forgot to mention, both of those are described in the help docs under Application Framework->Business Layer->Business Object Mapper->Customizing a Field if you need specific direction.
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