Friday, 25 April 2014

Find Customer list whom city exists in city array

String[] _cities = { "London", "New Delhi" };

var _customers = new[] { new { Name = "Saurabh", City = "London" },
 new { Name = "Sumit", City = "New Delhi" },
 new { Name = "Rohit", City = "London" },
 new { Name = "Rahul", City = "Mumbai" },
 new { Name = "Suresh", City = "London" },
 new { Name = "Sunil", City = "New Delhi" },
 new { Name = "Mahesh", City = "Agra" }
 };

var _query = from c in _customers
 where (_cities).Contains(c.City)
 select c;
Share:

0 Comments:

Post a Comment