EDIT: I haven't noticed break;until
If there can be more than one type with the corresponding identifier, then you need to use FirstOrDefaultin accordance with Keith's answer or my second code example below.
EDIT: "multi-from", , /hashcode type.Id.
, , :
var query = from s in vars
join type in statusList on s equals type.Id
select new NameValuePair(type.Id, type.Text);
foreach (var pair in query)
{
Add(pair);
}
, AddRange, IEnumerable<NameValuePair>, AddRange(query).
LookUp. "s".
var lookup = types.ToLookup(type => type.Id);
foreach (var s in vars)
{
var types = lookup[s];
if (types != null)
{
var type = types.First();
Add(new NameValuePair(type.Id, type.Text));
}
}
, , .