locked
adsm:type and Nullable weirdness RRS feed

  • Question

  • When a field is nullable on an entity the adsm:type is serlaized in a strange way.  I am assuming this is because the literal .Net type is being serialized:

     

    <adsSurpriseRDER_SEQ adsm:type="Nullable`1[System.Int64]" ads:null="true" />

     

    But when a field is not nullable, you get:

     

    <ads:CODE_ID adsm:type="Int64">180</ads:CODE_ID>

     

    This seems inconsistent.  Shouldn't the type always be Int64 and ads:null="true" like this:

     

    <adsSurpriseRDER_SEQ adsm:type="Int64" ads:null="true" />

     

     

    Thanks,

    -Scott

     

     
     
     
    Friday, March 14, 2008 2:33 AM

Answers

  • That design is intentional since nullable int is first class primitive type.  Think about the case where the value is not null, but the type still needs to be nullable int.


    Friday, March 14, 2008 3:54 AM
    Moderator
  •  

    As far as i know, there is no standard way. Even the type attribute is Astoria specific. The other option would be to add another attribute to indicate where the type is nullable or not. But then it would be confusing when the value was null - both IsNullable and IsNull attribute will show up with true values. So we decided to go with the CLR route and include the nullability constraint in the type information itself.

     

    Let us know if you have better suggestions. We would love to hear them.

     

    Thanks

    Pratik

    Saturday, March 15, 2008 5:11 PM
    Moderator

All replies

  • That design is intentional since nullable int is first class primitive type.  Think about the case where the value is not null, but the type still needs to be nullable int.


    Friday, March 14, 2008 3:54 AM
    Moderator
  • Ok.  I understand.  Is there more of a "standard" way to suport this in APP?  It seems a lttle proprietary to just serialize the .Net type info like this.

     

    Thanks,

    -Scott

     

    Friday, March 14, 2008 2:27 PM
  •  

    As far as i know, there is no standard way. Even the type attribute is Astoria specific. The other option would be to add another attribute to indicate where the type is nullable or not. But then it would be confusing when the value was null - both IsNullable and IsNull attribute will show up with true values. So we decided to go with the CLR route and include the nullability constraint in the type information itself.

     

    Let us know if you have better suggestions. We would love to hear them.

     

    Thanks

    Pratik

    Saturday, March 15, 2008 5:11 PM
    Moderator