2013-10-10 37 views
0

是否有可能使用Breeze控制器使用OData服務(使用.Net MVC實現)?添加服務引用到微風odata服務

我嘗試從客戶端應用程序添加服務引用,但在服務上使用Breeze控制器時,它無法找到服務端點。

任何幫助將不勝感激。

+0

你試過Google搜索'微風odata'嗎? –

回答

0

是,在服務器上,您將需要創建一個WCF DataService的,是這樣的:

[ServiceBehavior(IncludeExceptionDetailInFaults = true)] 
public class ODataService : DataService<Your_EF_DbContext> { 

    // Add your Entity Set names here ... for example 
    config.SetEntitySetAccessRule("Customers", EntitySetRights.All); 
    config.SetEntitySetAccessRule("Orders", EntitySetRights.All); 
    config.SetEntitySetAccessRule("Employees", EntitySetRights.All); 

    // V3 supported in our next release as well. 
    config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; 
    config.UseVerboseErrors = true; 
} 

然後從微風客戶端,您將需要調用

breeze.config.initializeAdapterInstance("dataService", "OData"); 

初始化微風的的OData處理。然後你創建一個EntityManager並連接到你的服務。例如:

var myEntityManager = new breeze.EntityManager("http://localhost:9009/ODataService.svc"); 

您現在可以通過EntityManager查詢並保存您的數據服務。