2014-02-09 14 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

相关问题