How to serialize a protected property in wcf
Posted
by Denis Rosca
on Stack Overflow
See other posts from Stack Overflow
or by Denis Rosca
Published on 2010-05-30T18:46:51Z
Indexed on
2010/05/30
18:52 UTC
Read the original article
Hit count: 422
Hello, i need some help with wcf serializing.
I have two classes Person and Address. The Address class looks like this:
public class Adresa : IExtensibleDataObject
{
private Guid _id;
[DataMember]
protected virtual Guid Id
{
get { return _id; }
set { _id = value; }
}
private ExtensionDataObject _extensionData;
[DataMember]
public virtual ExtensionDataObject ExtensionData
{
get
{
return _extensionData;
}
set
{
_extensionData = value;
}
}
private string _street;
[DataMember]
public virtual string Street
{
get { return this._cUTAM; }
set { this._cUTAM = value; }
}
private string _number;
[DataMember]
public virtual string Number
{
get { return this._number; }
set { this._number = value; }
}
private string _postalCode;
[DataMember]
public virtual string PostalCode
{
get { return this._postalCode; }
set { this._postalCode = value; }
}
// and some other stuff related to the address
}
The Person class looks like this:
public class PersoanaFizica :IExtensibleDataObject
{
private Guid _id;
[DataMember]
protected virtual Guid Id
{
get { return _id; }
set { _id = value; }
}
private ExtensionDataObject _extensionData;
[DataMember]
public virtual ExtensionDataObject ExtensionData
{
get
{
return _extensionData;
}
set
{
_extensionData = value;
}
}
private string _firstName;
[DataMember]
public virtual string FirstName
{
get { return this._firstName; }
set { this._firstName = value; }
}
private string _lastName;
[DataMember]
public virtual string LastName
{
get { return this._lastName; }
set { this._lastName = value; }
}
}
The problem is that when the wcf client the data the Id properties are set to a bunch of zeros ( something like 000000-0000-000000-0000000).
Any ideas on why this is happening? Thanks, Denis.
© Stack Overflow or respective owner