This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi everyone - usual disclaimer: very new to LS etc. etc.: Using LightSpeed4 Professional and I'm playing around with converting a column to an enum as outlined here: http://www.mindscapehq.com/documentation/lightspeed/Working-with-Models-in-the-Visual-Designer/enums-and-other-user-defined-types Scenario Table Session has a column ApplicationCode, which is a string simply representing the name of the application e.g. "App1", "App2". I have created a ApplicationConfiguration.ApplicationCode enum with the permitted values. I have a User Defined Type set up in my model called ApplicationCodeEnum, originally set up following the 'Add an Enum Type to the Designer', with the CLR TypeName of ApplicationConfiguration.ApplicationCode and ConverterType of Mindscape.LightSpeed.FieldConverters.StringEnumFieldConverter<ApplicationConfiguration.ApplicationCode> Problem Session.ApplicationCode is nullable/optional. When I run the code in the scenario where the Session.ApplicationCode column is null, the StringEnumFieldConverter can't figure out how to convert System.DBNull into a string.
I have tried without joy.
How can I convince lightspeed or the converter that DBNull is okay? Is the only solution to write my own converter ala http://www.mindscapehq.com/documentation/lightspeed/Working-with-Legacy-Databases/Mapping-Database-Types-to-Domain-Types ? Many thanks for any help you can provide! |
|
|
StringEnumFieldConverter doesnt support nullables so you will need to implement a custom converter so you can use a nullable enum on your properties. Here is the code for the current one, you should adapt this by making it deal with
Let me know how you get in with this :)
|
|
|
Thanks Jeremy - good to know it wasn't worth trying to continue down a useless path! Custom converter and we're away. Appreciate the quick reply. |
|