1

我正在使用新的 VS2013 并创建了具有 2 个模型、商店和产品作为客户端的 OData 控制器我使用了 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/$metadata#Store","value":[ { "odata.type":"WebApplication1.Models.Store","odata.id":"/odata/Store(1) ","Products@odata.navigationLinkUrl":"/odata/Store(1)/Products","Products":[ { "odata.type":"WebApplication1.Models.Product","odata.id":/odata /Product(1)","ID":1,"Name":"1" },{ "odata.type":"WebApplication1.Models.Product","odata.id":"/odata/Product(2 )","ID":2,"Name":"2" } ],"ID":1,"Name":"1" },{ "odata.type":"WebApplication1.Models.Store"," odata.id”:/odata/Store(2)","Products@odata.navigationLinkUrl":"/odata/Store(2)/Products","Products":[ { "odata.type":"WebApplication1.Models.Product"," odata.id":"/odata/Product(2)","ID":2,"Name":"1" },{ "odata.type":"WebApplication1.Models.Product","odata.id" :"/odata/Product(3)","ID":3,"Name":"2" } ],"ID":2,"Name":"1" } ] }"1" },{ "odata.type":"WebApplication1.Models.Product","odata.id":"/odata/Product(3)","ID":3,"Name":"2" } ],"ID":2,"姓名":"1" } ] }"1" },{ "odata.type":"WebApplication1.Models.Product","odata.id":"/odata/Product(3)","ID":3,"Name":"2" } ],"ID":2,"姓名":"1" } ] }

4

0 回答 0