'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported

后端 未结 8 530
粉色の甜心
粉色の甜心 2020-11-27 05:57

I am trying to execute the following code and am receiving an error

public List GetLoggingData(DateTime LogDate, string title)
{
     var context          


        
8条回答
  •  余生分开走
    2020-11-27 06:08

    Not the greatest solution, but it works. For a variety of reasons, I have to use .net 3.5 at this point and modifying the database would be difficult. Anyways, here is a solution that works:

                var query = from t in context.Logs
                          where t.Title == title 
                          && t.Timestamp.Day == LogDate.Day
                          && t.Timestamp.Month == LogDate.Month
                          && t.Timestamp.Year == LogDate.Year
                          select t;
    

    Not the most elegant solution, but it is effective.

提交回复
热议问题