I have the following code:
public IEnumerable<Report> GetReport(int reportId)
{
var dbReport = dbContext.ReportsTbl.Where(w =>w.ID == reportId);
return dbReport;
}
What I like to do though us to get First
If I do:
public IEnumerable<Report> GetReport(int reportId)
{
var dbReport = dbContext.ReportsTbl.First(w =>w.ID == reportId);
return dbReport;
}
How do I get it to do First(). It is complaining about it being IEnumerable.
You need to change the method signature to return only a single object instead of a collection:
If for some reason you do actually want a collection containing only the first element you could use
.Take(1)instead ofFirst.