0
votes

Gurus,

Here is my scenario:

I am defining a new client-side property (i.e. fullName) on one my entities using breeze's registerEntityTypeCtor function. The fullName property is coded to check the values of the firstName and lastName properties on the entity to determine it's value. It works when I am doing a query and receiving entities back from the db.

However, when I create a new entity on the client side (calling breeze's createEntity function) or make changes to the firstName or LastName properties without doing a save, then the custom fullName property is never updated until I perform another db pull. With breeze change tracking shouldn't the fullName property update any time either of the name properties changes?

During debug, I noticed that when I use a getter in code: (i.e. var fullName = entity.fullName) -- as I step through the code the ctor is hits the "backingStore" value of my entity which is either default value (using the createEntity) or the last db value, but never the current value of the entity.

What am I missing? Thanks

Here is an example I used for setting up the property:

function registerSpmoleSurvey(metadataStore) {
        metadataStore.registerEntityTypeCtor('SpmoleSurvey', spmoleSurvey);

        function spmoleSurvey() { }

        Object.defineProperty(spmoleSurvey.prototype, 'fullName', {
            get: function () {
                var ln = this.lastName;
                var fn = this.firstName;

                return ln ? fn + ' ' + ln : fn;
            }
        });

    }
2

2 Answers

0
votes

Look at this page for examples of adding computeds to your Breeze entities -

http://www.breezejs.com/documentation/extending-entities

Pass in an anonymous function as the third parameter that extends the entity.

0
votes

HI figure out what I was doing wrong...seems that I was a victim of camelCasing and I capitalize the property name inappropriately. Wrong as advertise now :}