How to use multi condition in where of list c# [closed]

I don’t now exactly what your code does but I suggest you try to see if there are any dates in a collection that match with a given date (see example 2).

Or if you are trying to get the elements that match a given date use example 1

      // example date
       DateTime date = new DateTime(2005,4,10);
      // data collection
      List<QueryRow> queryResult = App.StorageRepository.Query("appointments_appointment");

(Example 1 Where())

Use where to check where the date of QueryRow is equal to the given date. If it does return that QueryRow.

       IEnumerable<QueryRow> results = queryResult.Where(item => Convert.ToDateTime(item.Document.GetProperty("startDate")) == date)

       // loop the result items that matched the search result
       foreach (QueryRow result in results)
       {
           // do something with the row
       }

(Example 2 Any())

Check if the given date exists in collection. By using any it will check if there are any matching items with the date that is equal to the given date. If thre is on it will return true else false.

  bool dateExists = queryResult.Any(item => Convert.ToDateTime(item.Document.GetProperty("startDate")) == date);

Browse More Popular Posts

Leave a Comment