1

我是 WCF 新手,不知道出了什么问题,我收到以下错误:

WcfServiceLibrary.ReportServiceCO' 没有实现接口成员'WcfServiceLibrary.IReport.GetAllOrdersForCustomer(int)'

界面:

[ServiceContract]
interface IReport 
{
   // [OperationContract]
   // List<ModelData> GetAllCustomer();
    [OperationContract]
    List<ORDER> GetAllOrdersForCustomer(int _customerid);
}

班上:

class ReportServiceCO : IReport
{

    public List<ORDER> GetAllORDERsForCustomer(int _customerid)
    {
        List<ORDER> orders = new List<ORDER>();
        TestEntities ent = new TestEntities();
        var orders3 = from x in ent.ORDERs
                      where x.CUSTOMERID == _customerid
                      select new { x.ORDERID, x.DATA, x.CUSTOMERID, x.VALOARE };
        foreach (var i in orders3)
        {
            ORDER o = new ORDER();
            o.ORDERID = i.ORDERID;
            o.CUSTOMERID = i.ORDERID;
            o.DATA = i.DATA;
            o.CUSTOMERID = i.CUSTOMERID;
            o.VALOARE = i.VALOARE;
            orders.Add(o);
        }
        return orders;
    }
}
4

2 回答 2

5

方法名称区分大小写:

interface它声明为:

GetAllOrdersForCustomer

然而,实现被定义为:

GetAllORDERsForCustomer

它需要是:

public List<ORDER> GetAllOrdersForCustomer(int _customerid) 
{

}
于 2013-03-28T11:07:00.597 回答
1

将 GetAllORDERsForCustomer 重命名为 GetAllOrdersForCustomer。

于 2013-03-28T11:07:03.193 回答