I hit this snag too and decided to use extension methods. For instance:
public static class PersonExtensions { public static int GetAge(this Person person) {
Then in your DataServices consumer you can:
person.GetAge()
Yes, this is not as good as person.Age , but you also do not add unnecessary database columns.
Update:
Another alternative is to extend the Person class contained in the service reference. You can do this by creating a partial Person class with the same namespace as the Service class Person class. For instance:
public partial class Person { public string int Age { get { return (DateTime.Now - this.DateOfBirth).TotalDays / 365; } } }
Then the DataServices Person model will have the Age! Property
source share