I have two tables in my MS Sql database, Course and StudyCase, with a FK ID (Course table) to Course_ID (in the StudyCase table). I am trying to find the StudyCase ID from the Course id.
In the Repository:
public IQueryable<StudyCase> ListStudyCases(long courseId)
{
return _dbContext.StudyCases.Where(c => c.Course_ID == courseId);
}
In the StudyCases Services:
public IQueryable<StudyCase> ListStudyCases(long courseId)
{
return this._StudyCaseRepository.ListStudyCases(courseId);
}
In the StudyCases IServices:
IQueryable<StudyCase> ListStudyCases(long courseId);
Sending the action from the course controller:
return RedirectToAction("Index", "CourseCases", new { courseId = 6 });
In the StudyCase Controller:
public ActionResult Index(long courseId)
{
string id = "";
id = _studyCaseSvc.ListStudyCases(courseId).First().ID.ToString();
StudyCase cases = _studyCaseSvc.GetStudyCase(id);
...
I get the following two error:
Cannot implicitly convert type 'string' to 'long'
and
The best overloaded method match for 'IStudyCaseService.GetStudyCase(long)' has some invalid arguments
Would appreciate your help.
Just use your action argument without converting it to string.