Handling Nillable items and xsi:Nil

If an item is marked as Nillable in a schema:
<xsd:element name="author" type="bs:authorName" nillable="true" />

The code generator will generate a new class generated for the Nillable item:
public bs.Author_Nillable Author { get; set; }

The Nillable class will contain an IsNil property:
public Boolean IsNil

Setting this IsNil = true will omit cause the xml written out to show the item as xsi:Nil.

This is not the same as setting optional types to Null, this is covered in the article:
http://www.liquid-technologies.com/SmarterTrack/KB/a55/setting-empty-values-using-isvalid-and-null.aspx

Add Feedback