Wednesday, April 20, 2011

WCF nullable enumeration type

Does WCF support nullable enums? I have a DataMember that is a nullable enum type on the server-side however, when I generate a client-side proxy the type in the proxy is non-nullable.

From stackoverflow
  • Is there a (propertyname)Specified property of type boolean?

    public enum MyEnumType { EnumValue1, EnumValue2 }
    
    public MyEnumType MyEnumValue;
    public bool MyEnumValueSpecified;
    

    Do you have a "MyEnumValueSpecified" of type bool in your WCF proxy?

    WCF uses this to define whether or not a particular property has been specified or not.

    That way, even if the property is of type "Enum....." it can be "nullable".

    Marc

    : No, the "Specified" property is not currently generated...

0 comments:

Post a Comment