locked
search object list RRS feed

  • Question

  •         List<object> tableList = new List<object>();
            Table t = tableList.FirstOrDefault(item => item.
    
    I am very new to LINQ and searching lists.  Regardless, I am trying to search a list of objects on a text property called tableName.  I am confused when I try to enter the search criteria that I do not get the popup list of the object's properties.
    Monday, February 2, 2015 10:28 PM

Answers

  • That's because your list is a list of objects, so the compiler can't tell at compile time that it's actually dealing with Tables.

    Try using the actual class to declare the List.

    List<Table> tableList = new List<Table>();


    • Edited by Ante Meridian Monday, February 2, 2015 11:19 PM I meant compile time, not run time.
    • Marked as answer by JeffreyShumaker Monday, February 2, 2015 11:20 PM
    Monday, February 2, 2015 11:18 PM

All replies

  • That's because your list is a list of objects, so the compiler can't tell at compile time that it's actually dealing with Tables.

    Try using the actual class to declare the List.

    List<Table> tableList = new List<Table>();


    • Edited by Ante Meridian Monday, February 2, 2015 11:19 PM I meant compile time, not run time.
    • Marked as answer by JeffreyShumaker Monday, February 2, 2015 11:20 PM
    Monday, February 2, 2015 11:18 PM
  • thanks!
    Monday, February 2, 2015 11:20 PM