C# Linq Net Core: Exclude Words which contain search term

314 Views Asked by At

How do I conduct String Not Contains 'paraphrase key term' in Linq Net Core 2?

For this one, trying to acquire in the list which do Not contain 'ag' in the Product Name.

foreach (var product in Products().Where(c=>c.ProductName.NotContains("ag")))
2

There are 2 best solutions below

0
Mhsn On BEST ANSWER
foreach (var product in Products().Where( c => !c.ProductName.Contains("ag")))

Thats it

0
Saeid Babaei On

Check this:

foreach (var product in Products().Where(c=> !c.ProductName.Contains("ag")))