Open mahish opened 2 years ago
No, there is not. EntityKey.toString()
creates a human readable representation. If you want to serialize/deserialize the key use EntityKey.toJSON()
and EntityKey.fromJSON()
.
You can also look at the 'keyProperties' of the EntityType and then extract them from the entity yourself directly. See http://breeze.github.io/doc-js/api-docs/classes/entitytype.html#keyproperties
Thank you. I use the human readable version of EntityKey
to create unique ID for presentation layer of my app (since it is more specific and safe than simple FK value). Eg.:
id: entityKey.toString(),
get parentId() {
...
return parentEntityKey.toString();
},
set parentId(parentEntityKey) {
...
// change value of FK property
this.entity[propertyName] = parentEntityKey.split("-")[1];
}
As I can see there is specific mechanism with globally defined ENTITY_KEY_DELIMITER
to get the string. So it would be nice to have a built-in method to parse it back. .toJSON
does not help me here.
Hi, I didnt find native way how to parse back a value returned from
EntityKey.toString()
(doc). I can see the returned string value is concatenated as follows:[EntityType.name, foreignKeyValue].join('-')
. Is there any native, correct way how to get the FK(s)? Of course, I can doentityKeyString.split("-")[1]
but feels dirty. Am I missing something? Thanks.