我正在使用新的VS2013并使用2个型号创建OData Controller,Store和Products作为客户端我使用过KO,BreezeJS和DataJs 我看到扩展无法正常工作,我已将此问题发送到codeplex网站的微软人员,他们告诉我,我的代码一切正常
my.vm = {
stores: ko.observableArray([]),
load: function () {
var serverAddress = "/odata";
breeze.config.initializeAdapterInstances({ dataService: "OData" });
var manager = new breeze.EntityManager(serverAddress);
var query = breeze.EntityQuery.from("Store").expand("Products");
manager.executeQuery(query, function (data) {
var results = data.results;
$.each(data.results, function (i, c) {
my.vm.stores.push(c);
});
});
}
};
添加请求/响应
http://localhost:16894/odata/Store?$expand=Products
{
“odata.metadata”: “/的OData / $元数据#商店”, “值”:[ { “odata.type”: “WebApplication1.Models.Store”, “odata.id”: “/的OData /存储(1)”, “Products@odata.navigationLinkUrl”: “/的OData /存储(1)/产品”, “产品”:[ { “odata.type”: “WebApplication1.Models.Product”, “odata.id”:/的OData /产品(1)”, “ID”:1, “名称”: “1” },{ “odata.type”: “WebApplication1.Models.Product”, “odata.id”: “/的OData /产品(2)”, “ID”:2, “名称”: “2” } ], “ID”:1, “名称”: “1” },{ “odata.type”: “WebApplication1.Models.Store”, “odata.id”:/的OData /存储(2) “ ”Products@odata.navigationLinkUrl“: ”/的OData /存储(2)/产品“,”产品“:[ { “odata.type”: “WebApplication1.Models.Product”, “odata.id”: “/的OData /产品(2)”, “ID”:2, “名称”: “1” },{ “odata.type”: “WebApplication1.Models.Product”, “odata.id”: “/的OData /产品(3)”, “ID”:3, “名称”: “2” } ], “ID”:2, “名称”: “1” } ] }