I have 2 DTO files, with one of them being a sub-class of the other. The fields on the super-class are as follows:
[JsonProperty]
protected int financialFormatHeaderID;
[JsonProperty]
protected string financialFormatHeaderCode;
[JsonProperty]
protected string description = string.Empty;
[JsonProperty]
protected FinancialFormatPurpose purpose = FinancialFormatPurpose.Standard;
[JsonProperty]
protected IList<FinancialFormatDetailDto> details = new List<FinancialFormatDetailDto>();
[JsonProperty]
protected bool active = true;
The sub-class has this:
public RecoveryFormatHeaderDto()
: base() {
this.purpose = FinancialFormatPurpose.Recovery;
}
[JsonProperty]
private bool isPerSquareArea;
They both have the JsonObject(MemberSerialization.OptIn) and Serializable attributes above the class name (but under the namespace).
My problem is that when I try to save an instance of the sub-class I get the following error:
Newtonsoft.Json.JsonSerializationException was unhandled by user code
Message=A member with the name 'financialFormatHeaderID' already exists on 'RecoveryFormatHeaderDto'. Use the JsonPropertyAttribute to specify another name.
Source=Newtonsoft.Json
What is happening here? How do I fix this?
EDIT: Class signatures are as follows:
public class FinancialFormatHeaderDto
public class RecoveryFormatHeaderDto : FinancialFormatHeaderDto