The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties

后端 未结 10 2104
再見小時候
再見小時候 2020-11-28 02:47

Using this code in Entity Framework I receive the following error. I need to get all the rows for a specific date, DateTimeStart is of type Dat

10条回答
  •  感情败类
    2020-11-28 03:18

    I would like to add a solution, that have helpt me to solve this problem in entity framework:

    var eventsCustom = eventCustomRepository.FindAllEventsCustomByUniqueStudentReference(userDevice.UniqueStudentReference)
                    .Where(x =>  x.DateTimeStart.Year == currentDateTime.Year &&
                                 x.DateTimeStart.Month== currentDateTime.Month &&
                                 x.DateTimeStart.Day == currentDateTime.Day
        );
    

    I hope that it helps.

提交回复
热议问题