I'm using WCF Data Services for a RESTful API that returns a JSON response.
consider this object:
[Table("person")]
public class Person
{
[Column("dob", TypeName = "datetime")]
public DateTime DateOfBirth { get; set; }
[NotMapped]
public int Age
{
get { return CalculateAge(); }
set { }
}
}
WCF does not treat this object as I would expect. My service request completely ignores the Age property in the serialization of the Person object.
I've been using a workaround where I map the Age property to a dummy database column and I create a setter that does nothing. What an ugly hack! Is there a better way to have a DataService return a property that is not mapped to a database column?