微风importEntities [英] Breeze importEntities

查看:83
本文介绍了微风importEntities的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在加载应用程序时,我将导出一些微风实体,并将其存储在本地缓存中,以便稍后当我不得不再次使用这些实体时,将它们从本地存储中导入并在本地执行查询。

When my application loads, I am exporting few breeze entities and storing those in local cache so that later when I have to make use of those entities again, I import them back from local storage and execute the query locally.

有一个实体有84389行。我已经注意到,importEntites需要更长的时间来执行此实体。有什么方法可以加快速度吗?

There is one entity that has 84389 rows. I have noticed that the importEntites take longer to execute for this entity. Is there a way I can speed up this ?

var entities = manager.getEntities('Client');
var exportedEntity = manager.exportEntities(entities, { includeMetadata: false });

我正在将exportedEntity存储在缓存中。

I am storing exportedEntity in cache.



I am importing the above exportedEntity into entitymanager after fetching from cache.

entityManager.importEntities(exportedEntity);

上面的语句对于Client实体花费的时间更长。客户端表中有80K行。我不确定这是否会降低importEntities方法的执行速度。
导入实体后,我也在本地执行查询。

The above statement takes longer for the Client entity. The client has 80K rows in table. I am not sure if that reduces the execution speed for importEntities method. I am also executing query locally after the entity is imported.

推荐答案

我认为您的意思是您拥有实体类型客户端,具有84k行/实体。

I think you mean that you have an EntityType, Client, with 84k rows/entities.

有很多对象。我将重新考虑是否应将这些数据视为丰富的Breeze实体,还是应将它们以更简单,更紧凑的形式保存为数据对象。我强烈倾向于后者,尤其是如果它们是只读的。将只读数据表示为实体的好处较少,在这种情况下,性能和内存使用率较低的可能性更大。

That's a lot of objects. I would reconsider whether that data should be treated as rich Breeze entities or if they should be held in a simpler, more compact form as data objects. I'm leaning strongly to the latter, especially if they are read-only. There is less benefit to representing read-only data as entities and, at these volumes, bad performance and memory usage are more likely.

请记住,并非所有数据都必须是实体,Breeze很高兴获取实体数据和原始数据的组合。混合应用程序很常见。

Remember that not all data have to be entities and Breeze is happy to fetch a mix of entity and raw data. Hybrid apps are quite common.

如果您仍想探索将它们视为实体,则可以尝试使用以下export命令,该命令将给定类型的所有实体输出为JSON:

If you still want to explore treating them as entities, you might try the following export command which outputs all entities of a given type as JSON:

var exported = manager.exportEntities('Client', {asString:false, includeMetadata:false});

结果可以像以前一样导入。

The result can be imported as before.

var imported = manager.importEntities(exported);

可以提高(或不提高)进出口速度。

This may improve export and import speed (or not).

您以后不必再在本地查询。所有导入的实体都在 imported.entities 中。

You don't have to query locally afterward. All the imported entities are in imported.entities.

这篇关于微风importEntities的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆