If Else in linq query RRS feed

  • Question

  • I've a list like the below:


    Id     IsContact 
    1        true
    2        false
    3       false
    4      false

    In the above list there would be only one item with the IsContact is true. For all remaining items IsContact is false. Now need to get the id of the list item which has IsContact is true, if the item with IsContact true is not available then return the second item id from the list.

    For example: From the above list return id 1


    Id   IsContact
    10   false
    12   false

    from list2 return id 10 which is the first item. How to query for the id from single list?
    Wednesday, December 2, 2009 1:50 AM