Friday, April 25, 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;

No comments :

Post a Comment

AJAX, asp, Asp.net, asp.net and sql server security, Asp.net IntemIndex, C#, Css, DataBinder.Eval, DataKeyNames, Datalist, Datapager, DataSet, DataTable, DropDownList, FindControl, gridview, JavaScript, jquery, Listview, Paging, Regex, RegularExpression, Repeater, Server side validation, Sql Server, timer, timercallback, Validation, XML, xmlnode, XPath