2014-02-09 12 views
0

這是我的代碼:給定的名字沒有在業務運營中發現

// This method is called only once to initialize service-wide policies. 
public static void InitializeService(DataServiceConfiguration config) 
{ 
    // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc. 
    // Examples: 
    config.SetServiceOperationAccessRule("getSMSs", ServiceOperationRights.All); 
    config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3; 
} 
public IQueryable<SM> getSMSs() 
{ 
    SelfServiceEntities db = new SelfServiceEntities(); 
    return from d in db.SMS select d; 
} 

我得到這個異常:

The given name 'getSMSs' was not found in the service operations. 

回答

3

你需要定義你的方法service operation

[WebGet] 
public IQueryable<SM> getSMSs() 
{ 
+0

它的工作原理,非常感謝。我還有一個問題。我想使用WCF數據服務來構建我的web服務。所以,我所需要做的就是像'getSMSs'這樣的函數嗎?並打電話給它?我知道我必須定義我應該使用的實體。但我正在問這個architucure。我不需要班級嗎? – user2059935

相關問題