【发布时间】:2014-05-05 14:42:38
【问题描述】:
我只有客户端 Metadatstore:
initialize = (metadataStore) => {
metadataStore.addEntityType({
shortName: "AppsListHelper",
namespace: NFL.settings.entityNamespace,
dataProperties: {
Path: { dataType: "String" },
Title: { dataType: "String", isPartOfKey: true },
Author: { dataType: "String" },
Description: { dataType: "String" },
ImageUrl: { dataType: "String" },
IsFavourite: { dataType: "Boolean" },
AppTypeName: { dataType: "String", isPartOfKey: true },
Departments: { dataType: "String" },
AlwaysShownTo: { dataType: "String" },
AvailableTo: { dataType: "String" },
HasAccess: { dataType: "Boolean" },
Keywords: { dataType: "String" }
}
});
metadataStore.registerEntityTypeCtor('AppsListHelper', function () { this.IsMyApp = ko.observable(false); });
}
我想添加其他属性“IsMyApp”,仅用于客户端使用 - 在我的一种 GET 方法中,我将此属性设置为“true”:
querySucceded = (data) => {
ko.utils.arrayForEach(data.results, (item: m_application.Application) => {
item.IsMyApp(true);
});
return this.apps(data.results);
}
现在我尝试通过微风管理器查询本地数据,使用查询:
private getLocal = (resource) => {
var query = this.EntityQuery.from(resource).where('IsMyApp', '==', 'true').toType("AppsListHelper");
return this.breezeManager.executeQueryLocally(query);
}
但没有任何反应(视图已加载但为空白),删除“where 子句”的行后,它返回所有数据。
任何帮助将不胜感激:)
我更详细的场景如下:我有 2 个视图:“我的应用程序”和“所有应用程序”。由于所有实体都是相同类型的“AppsListHelper”,因此在我从服务器接收到带有数据的两个列表后,它们会一起缓存 - 当从本地缓存中提取时,这会导致相同的数据显示在两个视图上(我理解它)。因此,作为第一个解决方案,我只想在客户端添加额外的标志“IsMyApp”,因为我真的不需要在服务器上使用它,并根据该标志的值区分数据以获得适当的视图。
【问题讨论】:
-
我在帖子中添加了更多细节。谢谢!
标签: typescript breeze