I'm using JsonConvert
in my project in order to make a json
string from my object, but something weird is happening, one of entities losses data in the process, which is weird because when I'm debugging, the entity has values, but for some reason it gets lost during the process.
I use the JsonConvert.SerializeObject method, and this is my entity which looses data:
[DataContract]
public class MediaDTO : BaseEntityDTO
{
[DataMember(IsRequired = true)]
public int Id { get; set; }
[DataMember(IsRequired = true)]
public bool IsAlive { get; set; }
[DataMember(IsRequired = true)]
public string Description { get; set; }
[DataMember(IsRequired = true)]
public PidDTO Pid { get; set; }
}
[DataContract]
public class BaseEntityDTO
{
[DataMember(IsRequired = true)]
public bool IsDeleted { get; set; }
[DataMember(IsRequired = true)]
public DateTime AddedDate { get; set; }
[DataMember(IsRequired = true)]
public DateTime UpdatedDate { get; set; }
}
public class PidDTO : BaseEntityDTO
{
public string PidId { get; set; }
public VidDTO Vid { get; set; }
public string Name { get; set; }
public virtual bool IsFromUser { get; set; }
}
public VidDTO : BaseEntityDTO
{
public virtual string VidId { get; set; }
public virtual string Name { get; set; }
public virtual bool IsFromUser { get; set; }
}
Now, when I Look at the json
, and I see all of the property from the BaseEntityDTO
class, but not the other properties of the class itself.
Any idea why, is there a problem with the entities or something like that?