I have the following entity base class marked as serializable:
[Serializable]
public abstract class EntityBase
{
public bool Is_ActiveNull = true;
[XmlElement(ElementName = "Is_ActiveFromNull")]
...
I have then concrete entity which inherits from base entity:
[Serializable]
public class ContactEntity : EntityBase
{
...
I have a WCF service which uses this entity as a input parameter in contract.
When I create a service reference from the client it creates a reference.cs which ignores default values for field Is_ActiveNull.
This is EntityBase class in reference.cs file:
public partial class EntityBase : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
{
private bool Is_ActiveNullField;
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
public bool Is_ActiveNull {
get {
return this.Is_ActiveNullField;
}
set {
if ((this.Is_ActiveNullField.Equals(value) != true)) {
this.Is_ActiveNullField = value;
this.RaisePropertyChanged("Is_ActiveNull");
}
}
}
...
In this case Is_ActiveNullField is set to false by default.
My question is how can I preserve the default value?
thanks
Their is no such attribute that will preserve the default value for public bool Is_ActiveNull
But you can achieve it when Deseralizing happens like this