How to Hand Null values in generated classes
Question asked by Brian Grant - February 1, 2018 at 2:50 PM
Answered
I have several xsd schemas that will map to org docs. Ive generated classes classes but am having major problems with these classes when working with my applications interface. The interface has to have null fields.
Example:
SimpleClass.NumerofItems
This would display to a text box has to be blank if a value is not or hasent  been   entered.
If this were a class I created id just use int? for the type on the NumerofItems property.
The classes generated by liquid xml don’t allow for this. Ive tried using nilable in the schema but I still don’t get null friendly properties in the generated classes. Ive tried loading xml docs into the class leaving the node out. They load fine but if you try using the property on the class to do any kind of compare it throws an error.
How can I handle this?

6 Replies

Reply to Thread
0
Liquid Support Replied
Employee Post
Hi,
 
Please see knowledge base article:
 
Basically you can only do this for complexTypes, simpleTypes require you to use the IsValid... properties.
 
I have added this to the requested features for review, as I think this is a valid concept for .Net languages. Although I guess in C++ we could also create a wrapper class to do this (as that is what .Net does for you).
 
 
0
Brian Grant Replied
Wow Im shocked that this hasn't come up before. It blows my mind that I can grab XSD2Code for free and have straight forward null handling. But I have to use these isvalid , isnull machinations in a product this expensive. Any idea how long that review process takes? Is there any code workaround I can do in the generated classes? If I cant get this to handle nulls properly Ill have to remove it from our application. That would suck considering Im the one that asked for the licenses for my team.
0
Liquid Support Replied
Employee Post
The dev team say this will be a small contained fix for them to change the templates and so we will provide this option in the new 2018 release, due on 12th February.
0
Brian Grant Replied
We licensed the 2017 version a few months ago. without maint. Will this be back ported to the 2017 version? Convincing my Org to drop a few thousand to get a fix for something that they can get for free in another community product is a non starter.
0
Liquid Support Replied
Employee Post
Please send an email containing your order or license information to:
sales@liquid-technologies.com
1
Liquid Support Replied
Employee Post Marked As Answer
Hi,
 
Liquid Studio 2018 is now available and includes an option to 'Generate Nullable Simple Types' :
 

Reply to Thread