本文介绍了带WCF数据服务的Breeze.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始探索js库breeze.js。我浏览了这些示例,但是似乎找不到任何有关如何使用WCF数据服务的示例(所有示例似乎都在Web API上)。

I just started exploring the js library, breeze.js. I've looked through the samples but can't seem to find any example on how to consume a WCF Data Service (all the examples seem to be on Web API).

是否有人知道如何使用breeze.js来使用WCF数据服务(或任何其他OData服务)?

Does any one know how to consume a WCF Data Service (or any other OData service) with breeze.js?

我在文档中仅阅读了breeze.js的某个地方目前支持对OData服务的读取。对我而言,这很好,因为我正在考虑的用例不包括对OData服务的写入。

I read somewhere in the docs that breeze.js only supports reads for OData services at the moment. That is fine by me as the use-case I'm considering it for does not include writes to the OData Service.

推荐答案

此答案中描述的配置不再正确!


我是Breeze的工程师之一。

The configuration described in this answer is no longer correct!

I am one of the engineers on Breeze.

与OData进行通讯的最简单方法

The simplest way to talk to an OData service with Breeze is to first configure breeze to talk to OData.

breeze.core.config.setProperties({
    // the OData provider
    remoteAccessImplementation: entityModel.remoteAccess_odata;
    // this is the Knockout provider but we also provide a Backbone provider
    //  and we have others on the way
    trackingImplementation: entityModel.entityTracking_ko,
});

,然后初始化EntityManager并进行第一个查询。

and then initialize an EntityManager and make your first query.

var myServiceName = "http://localhost:9009/ODataService.svc";
var em = new breeze.entityModel.EntityManager( {serviceName: myServiceName });

var query = breeze.entityModel.EntityQuery.from("Customers")
    .where("CompanyName", "startsWith", "B")
    .orderBy("City");

em.executeQuery(query).then(function(data) {
   // process the results here.
});

您应该能够以这种方式使用任何OData服务。

You should be able to consume any OData service in this manner.

上的Breeze文档可以提供很多帮助更多信息。

The Breeze docs at http://www.breezejs.com/documentation/introduction can provide a great deal more information.

另外,请告诉我们是什么让您觉得JayData更合适。这就是我们改进产品的方式。

Also, please let us know what it was that made you feel that JayData was a better fit. This is how we improve our product.

谢谢

这篇关于带WCF数据服务的Breeze.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 17:33