Reputation: 3857
Is there a way to stringify detached entity in breeze?
It is possible to do via
creating appropriate manager
...
manager.addEntity(myEntity);
var str = manager.exportEntities(myEntity);
I just search the simplest way to do it without using managers. something like JSON.stringify(myEntity)... but it returns an error.
any suggestions?
Upvotes: 0
Views: 111
Reputation: 17052
The problem is that entities have relationships with other entities, and the resulting graph can be recursive and is also often very large so you will need some method of serializing a possibly recursive entity graph. This is what is done inside of the exportEntities call.
If what you need is just the data properties of an entity then the code can be much simpler. Simply copy all of the data properties of an entity ( list of data properties is available from the entityType) into an empty javascript object and then stringify this copy. Of course this will not give you entityState information or originalValues for the entity, but I can't tell if you need these.
Upvotes: 1