I'm closely following John Papa's pluralsight course on Angular and Breeze. I also use Entity Framework 6.
At load time, I call a Prime function that clears the cache:
function clearCache() {
var cachedParents = manager.getEntities('Parent'); // all invoices in cache
cachedParents.forEach(function (parent) { manager.detachEntity(parent); });
zStorage.clear();
manager.clear();
}
and then, loads the info:
return EntityQuery.from('Parents')
.where('applicationUser.email', '==', userId)
.expand('Address, Children')
.toType(entityParent)
.using(self.manager)
.execute()
.then(querySucceeded, self._queryFailed);
that calls the controller with
[HttpGet]
public IQueryable<Parent> Parents()
{
return _repository.Parents;
}
That returns one record...
Later, on the loading of the view, in the same repository, I request the parent entity from the local cache as follows:
var cachedParents = EntityQuery.from('Parent')
.toType(entityParent)
.using(self.manager)
.executeLocally();
THIS ONE BRINGS TWO ENTITIES, the correct one with Id, name, addres, etc. but also brings an empty entity with Id 0.
I've checked and even if I call the local query right after the remote query, it still brings the correct record AND the empty record.
I also reviewed the response and the json object comes correctly formatted and with only one record.
I've tried clearing the zstorage, the entity manager, detachment of the object, but nothing seems to explain or clear the empty entity.
This behavior only happens in the Parent entity type. No other type shows anything wrong.
Thanks in advance.