A very simple question, yet I couldn’t find the answer.
Let’s say we have this:
[HttpPost]
public ActionResult Comparison(int id)
{
string makeLst = new List<String>();
var makeQry = from m in db.Car
where m.ID == id
select m.Make;
makeLst = makeQry.AddRange(makeQry);
ViewBag.make = new List<String>(makeLst);
return View();
}
The “makeQry” Result View would be just one word (String). So I wanted to not use List for this, and just use String. Using “.ToString()” won’t work since “makeQry.ToString()” would be the Query itself instead of the it’s results. And I checked there is no method such as for instance makeQry.Result or something to get the result of Query.
Thank you.
Details: If you know for sure there will always be a matching value for ID then the below should do the job (not tested)
or if you prefer to keep the linq syntax how you are doing it