开发者

ASP.NET MVC does not have the matching return type

I have the following code in my repository:

public PerformanceDetails performanceDetails(String name, String year)
{
    var PerformanceDetails = (from s in _db.PerformanceDetails where s.venue == name && s.year == year select s).First();

    return PerformanceDetails;
}

and then this is the interface:

Performance performanceDetails(String name, String year);

In the controller I have the following ActionResult:

public ActionResult Details(String name, String year)
{
    return View(_repository.performanceDetails(name, year));
}

As far as I can tell this should be fine but when I try and build the solution it gives an error saying:

Error 1 'u0558234_assignment2.Models.StageRepository' does not implement interface member 'u0558234_assignment2.Models.IStageRepository.performanceDetails(string, string)'. 'u0558234_assignment2.Models.StageRepository.performanceDetails(string, stri开发者_如何学运维ng)' cannot implement 'u0558234_assignment2.Models.IStageRepository.performanceDetails(string, string)' because it does not have the matching return type of 'u0558234_assignment2.Models.Performance'. C:\Users\cameron\Desktop\u0558234_assignment2\u0558234_assignment2\Models\StageRepository.cs 8 18 u0558234_assignment2

Any ideas what the problem is? Thanks


Your implementation of performanceDetails is returning PerformanceDetails not Performance


Your method must return Performance as declared in the interface and not PerformanceDetails. If you want to return details you will need to modify the interface you are implementing to reflect this change.


The return type in the interface is Performance, but the method has the return type PerformanceDetails.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜