Breeze - How to Load Navigation property from cache -
i getting single entity using method fetchentitybykey
, after loading navigation property entity entityaspect.loadnavigationproperty
. loadnavigationproperty
make call server, wondering if can first check cache, if exist there otherwise go server. how possible? here current code
return datacontext.getprojectbyid(projectid) .then(function (data) { vm.project = data; vm.project.entityaspect.loadnavigationproperty('messages'); });
here function encapsulated inside datacontext
service.
function getprojectbyid(projectid) { return manager.fetchentitybykey('project', projectid) .then(querysucceeded, _queryfailed); function querysucceeded(data) { return data.entity; } }
also, how possible load navigation property
limit. don't want have records navigation property @ once performance reason.
you can use entityquery.fromentitynavigation method construct query based on entity , navigationproperty . there can execute resulting query locally, via entitymanager.executequerylocally method. in example once have 'project' entity can following.
var messagesnavprop = project.entitytype.getproperty("messages"); var query = entityquery.fromentitynavigation(project, messagesnavprop); var messages = myentitymanager.executequerylocally(query);
you can make use of the entityquery.using method toggle query between remote , local execution, this:
query = query.using(fetchstrategy.fromlocalcache);
vs
query = query.using(fetchstrategy.fromserver);
Comments
Post a Comment