I followed some great advice here ( Handling calculated properties using breezejs and web api ) to allow Breeze to access my calculated properties, which I set in a partial class on the server side:
public partial class EventPerson { [NotMapped] public Decimal TotalAmountPaid { get { return this.EventPersonPayments.Sum(p => p.AmtPaid); } } }
But for each EventPerson event received, this value is displayed as 0 if I do not use server.expand ("EventPersonPayments") clients or .Include ("EventPersonPayments").
I do not want all data in EventPersonPayments to be serialized and sent to the client; all i want is the total value. Is it possible?
EDIT: if my computed property is derived from other properties already existing in the object, it works fine. For instance:
public partial class EventPerson { [NotMapped] public String DisplayName { get { return this.FirstName + " " + this.LastName; } } }
returns the value of DisplayName in the JSON payload. The first type of computed property always returns 0 or null, unless I specifically download all the additional information.
I decided to convert them to User Defined Functions in SQL Server, but I did not need to throw out the C # code to make it work as it should.
source share