我有这个从 EF 返回数据的 GREAT WCF 服务。
public class HistoryDataService : DataService<HistoryEntities>
{
#region Public Methods
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
}
[WebGet]
public IQueryable<History> GetHistoriesById(int recordId)
{
return CurrentDataSource.Histories.Where(d => d.RecordId == recordId);
}
#endregion
}
我还添加了其他服务,例如:
[WebGet(UriTemplate = "eventdetails/{id}", ResponseFormat = WebMessageFormat.Json)]
为了使它更像是一个传统的 RESTful 服务,但是,当我添加它时,我得到了各种错误,例如:
... both defines a ServiceContract and inherits a ServiceContract from type System.Data.Services.IRequestHandler.`
我如何添加这个属性,或者它甚至可能吗?