Cameron
Cameron

Reputation: 28853

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, string)' 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

Upvotes: 2

Views: 875

Answers (3)

Guffa
Guffa

Reputation: 700830

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

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1039478

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.

Upvotes: 0

Daniel A. White
Daniel A. White

Reputation: 191058

Your implementation of performanceDetails is returning PerformanceDetails not Performance

Upvotes: 3

Related Questions