user2585299
user2585299

Reputation: 883

Get property names present in a breeze entity

After I execute breeze query as shown below:

   var breezeQuery = function(){
    var query = EntityQuery.from('TableA')
                   .inlineCount();

        function querySuceeded(data) {
               //data.results[0] contains the entity
        }

        manager.executeQuery(query)
            .then(querySuceeded)
    }

I get the entity in data.results[0] which contains properties as well as other information like entityAspect etc. How can I get the property names present in a breeze entity ?

Upvotes: 0

Views: 184

Answers (2)

Ward
Ward

Reputation: 17863

Object.keys(data.result[0]) is the vanilla JavaScript way to get all properties of the data.result[0] object. Just saying.

Jay's way of course winnows those down to the properties monitored by Breeze, the persisted properties in particular. That's probably what you meant :-)

Upvotes: 1

Jay Traband
Jay Traband

Reputation: 17052

Use the MetadataStore. Something like this:

var tableAType = manager.metadataStore.getEntityType("TableA");
var dataProperties = tableAType.dataProperties;
var navigationProperties = tableAType.navigationProperties;

or from an instance of a entity ( not a projection), since every entity will have an 'entityType' property you can also do this:

var tableAType = tableAInstance.entityType;
var dataProperties = tableAType.dataProperties;
var navigationProperties = tableAType.navigationProperties;

Also see: http://www.breezejs.com/sites/all/apidocs/classes/EntityType.html

Upvotes: 1

Related Questions