在 \Samples\DocCode 中有三个组合远程 + 本地查询的示例。也许他们会有所帮助。
在此处添加评论。完整的代码在 queryTests.js
1. * 结合远程和本地查询获取所有客户 * 包括新的、未保存的客户 * v1 - 使用 FetchStrategy
2. * 结合远程和本地查询获取所有客户 * 包括新的、未保存的客户 * v1=使用 FetchStrategy.FromLocalCache
3. * 结合远程和本地查询获取所有客户 * 包括新的、未保存的客户 * v2=使用 ExecuteLocally()
一个关于如何不再这样做的有趣示例也可能会让您感兴趣(也在 queryTests 中:
/*********************************************************************
* This portion of the "queryTests (by id)" module
* tests a hand-built async getById utility that was the way to do it
* before EntityManager.fetchEntityByKey
* A curiosity now.
********************************************************************/
// This hand-built async getById utility method returns a promise.
// A successful promise returns the entity if found in cache
// or if found remotely.
// Returns null if not found or if found in cache but is marked deleted.
// Caller should check for query failure.
// 'queryResult' reports if queried the remote service
// and holds a found entity even if it is marked for deletion.
//
// This fnc has been replaced by EntityManager.getEntityByKey.