I am trying to fetch records from database in the sense that it should getrecords where name contains "searchKey" and name not in the excludeTerms array with comma seperated. How can I do this in Linq?
Rows = (from u in DB.Clients
where u.Name.Contains(searchTerm) && !u.Name.Contains(string.Join(",", excludeTerms.Select(s => "'" + s + "'").ToArray()))
select new ClientModel
{
Name = u.FullName,
Id = u.Id,
}).Take(5).ToList();
Where excludeTerms contains list of elements, such as
1)Sandy
2)Mandy
3)Larry etc
List<string> excludeTerms = new List<string>();