Try to use it for Like query in LINQ

 

public class Customer
    {
        public int ID
        {
            get;
            set;
        }
        public string Name
        {
            get;
            set;
        }
        public string Location
        {
            get;
            set;
        }
        public double Income
        {
            get;
            set;
        }
    }
 List<Customer> customerList = new List<Customer> { 
             new Customer
              ID = 1, Name = "Sekar L", Location = "Mumbai", Income = 21000 
                 }, 
             new Customer
                 ID = 2, Name = "Pawan S", Location = "Mumbai", Income = 40000 
             },               new Customer
                 ID = 3, Name = "Anil S", Location = "Mumbai", Income = 18000 
             },               new Customer
                 ID = 4, Name = "Kunal S", Location = "Mumbai", Income = 25000 
             },               new Customer
                 ID = 5, Name = "Robert B", Location = "Banglore", Income = 28000               }
            };

 

Linq Query 

 

  var result = from cust in customerList
                         where cust.Location.Contains("Banglore")
                         select cust;

 

Lambda Query 

 

  var result1 = customerList.Where(x =>x.Location.Contains("Banglore"));

0 Answers

Leave a answer

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

you may also like