在服务操作中找不到给定的名称

时间:2014-02-09 08:09:25

标签: c# entity-framework wcf-data-services

这是我的代码:

// 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.

1 个答案:

答案 0 :(得分:3)

您需要将方法定义为service operation

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