C# linq where like query Edit

Murugan Andezuthu Dharmaratnam | 21 September 2020 | 2499

I have a C# list of countries with properties Id and Name. I would like to filter the countries by Name with a like, like how you would using a SQL query like below

select * from SetupCountry where Name like '%Ind%'

Solution

solution is use the Contains with the Where LINQ

filter = "Ind";
List Countries = new Country().Get();
var retval = Countries.Where(x => x.Name.Contains(filter));