Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<bool>' to 'System.DateTime?' RRS feed

  • Question

  •  OldestOpenProblem = g.Where(x => x.State.Equals("Open", StringComparison.OrdinalIgnoreCase)).Select(x=>x.Created.Date < new DateTime(1970, 01, 01).Date)

    I need a list of dates based on this linq query but i get this error message please help

    • Edited by papipanne Tuesday, August 28, 2018 6:39 AM
    Tuesday, August 28, 2018 6:38 AM

All replies

  • Try Where instead of Select. (Both of Where can be combined using '&&'). 
    But, seems that you should give more details about OldestOpenProblem and the required results.
    Tuesday, August 28, 2018 7:10 AM
  • I'm not sure exactly what you are trying to select. So it would help if you explained the data and what you are trying to retrieve from it.

    But for your information, the Select() method essentially shapes (or 'projects') the data into a set of objects. You provide a method to Select() that is passed an object representing a row of data and the method must return a type, which can be either a simple type or a new (anonymous) object. The result is a set of that type.

    In your case you are returning "x.Created.Date < new DateTime(1970, 01, 01).Date"

    This is a boolean expression. Hence you are getting an IEnumerable<bool>.

    • Edited by RJP1973 Tuesday, August 28, 2018 10:48 AM
    Tuesday, August 28, 2018 10:47 AM