We are adding additional properties to our objects on the server that we do not track in the database. The data gets returned to the client but the object materialized by breeze does not have it as a property. How can we add properties to our objects that we return to breeze but not map them into the database where we store the data?
Example: Widget Class Property A - Mapped to Database Property B - Has [NotMapped] attribute so that it is not stored in the database. It is calculated on the fly by the server.
When we get the object on the client we get: Widget Class = { Property A: ko.observable(Value for A) }
Property B is missing.
When we look at the json returned by the server we see:
Widget Class = { Property A: Value for A, Property B: Value for B }
Properties with NotMapped attributes are not part of the MetaData generated by EFContextProvider, so those properties won't be available in the client side breeze entity. But in js you can extend the client side entity and add the property to the entityType yourself (with an initial value set). This will make sure that the value for the property is correctly set when the json object is retrieved from the server.
http://www.breezejs.com/documentation/extending-entities
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With