Hi guys i want to convert employee collection List to a IQueryable.

This is employee list:

List<Employee> Employee = new List<Employee>(){
            new Employee() {  Name = "Suresh", ID  = 1},
            new Employee() {  Name = "Sekher", ID =  2 },
              new Employee() {  Name = "Sumit", ID =  3 },
            new Employee() {  Name = "Pankaj", ID = 4 },
            new Employee() {  Name = "Rahul", ID = 5 }}.ToList();

  

Please help me.

 

1 Answers

  1. Aditya Kumar Patel
    Re:Convert List<T> type object to IQueryable<T> type arya mercy
    10/7/2018 6:16:04 PM

    AsQueryable method is used to convert given input list elements to IQueryable<T>.


    Try to use it:

    List<Employee> Employee = new List<Employee>(){
                new Employee() {  Name = "Suresh", ID  = 1},
                new Employee() {  Name = "Sekher", ID =  2 },
                  new Employee() {  Name = "Sumit", ID =  3 },
                new Employee() {  Name = "Pankaj", ID = 4 },
                new Employee() {  Name = "Rahul", ID = 5 }};
     
               IQueryable<Employee>result = Employee.AsQueryable().Where(x => x.Name.Contains("Suresh"));

    I hope it will help to you.


Leave a answer

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

You may also like