I have this code in the controller:
public ActionResult Details(int id)
{
using (var db = new MatchGamingEntities())
{
var MyMatches = from m in db.Matches
join n in db.MatchTypes on m.MatchTypeId equals n.MatchTypeId
where m.MatchId == id
select new MatchesViewModel
{
MatchType = n.MatchTypeName,
MatchId = m.MatchId,
MatchName = m.MatchTitle,
MatchDescription = m.MatchDescription,
Wager = m.Wager
};
ViewBag.MyMatches = MyMatches.ToList();
return View(MyMatches.ToList());
}
}
I want this query to return only one result, and I can use MyMatches as a MatchesViewModel object, so I do not need to use the function ToList(), thereby getting rid of IEnumberable on the view page @model IEnumerable<MatchGaming.Models.MatchesViewModel>so I can include it in this:@model MatchGaming.Models.MatchesViewModel
source
share