string popUpHTML="";
var xx = from Temp in TemplateList
where
(
Temp.TitleID == titleID
)
select Temp.HTML;
foreach (var s in xx)
{
popUpHTML = s.ToString();
}
The code above is working. The executed linq is supposed to return only one value. Is there any way I can get the result of the above LINQ without a foreach loop. (Sorry I am new to LINQ).
Update: titleID is a unique key in the database, hence only one result is expected.
Right now your query returns an
IEnumerable, instead useFirstOrDefault()(orSingle()if you are absolutely sure that there always will be exactly one result):