I am creating a LINQ query, and I want to have a NOT IN SQL-style clause to ensure that my result does not have one of the values ββfrom a comma-separated list.
I could not find a NOT IN clause for LINQ. Please suggest a solution.
You need to make a! Contained in the collection of objects that you want to exclude.
var excluded = new[] { 3, 7, 19, 41 }; var v = from i in Enumerable.Range(0, 100) where !excluded.Contains(i) select i;
You will need the .Except () operator.
var results = list1.Except(list2);
http://blogs.msdn.com/b/charlie/archive/2008/07/12/the-linq-set-operators.aspx http://www.hookedonlinq.com/ExceptOperator.ashx
Note. You will need to implement iEqualityComparor to use the Except method with complex types.
Something like that...
string items = "1,2,3,4"; var subList = items.Split(','); var result = list.Where(item=>!subList.Contains(item.SomeStringField));
Source: https://habr.com/ru/post/1346241/More articles:Regular iPhone Password Schedule - regexHow to automate password entry? - bashRegular expression for alphanumeric password with at least 1 number and character - javascriptDocument or blog for: Buying apps and Monotouch - iossaving schedule in mysql - mysqlIs there a shorthand for querying a dictionary in python? - pythonPython 3 CGI: how to output raw bytes - python-3.xUnit Testing in Visual Studio - unit-testingseveral sorts in the list - sortingIs it possible to add wpf ResourceDictionary to the application from the xaml file UserControl? - wpfAll Articles