I have an implicit variable taking a List containing the result of a SQL query (LINQ).
This set represents the existing clients of a list, previously selected.
Through a stored procedure I take a new set of clients that will be used to fill a drop down. Iterating through this set of data I exclude those records if already contained in the list of existing entries.
How could I do this check with implicitly typed variables?
var existingClients = (from doc in TBL_Documents
join c in TBL_CONTACT on doc.CONTACTID equals c.CONTACTID
where doc.DOCID.Equals(DocID)
select new { c.CONTACTID, c.FULLNAME }).ToList();
var resultSet = sp_ActiveContacts(index).ToList();
foreach (var record in resultSet)
{
//How could I achieve something like this if condition (like a List)?
if (!existingClients.Contains(record.CONTACTID))
{
optionTags += "<option value=" + record.CONTACTID + ">" + record.Name + "</option>";
}
}
If possible, I would prefere avoiding to create a temporary List to store the CONTACTID used for the if condition.