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

后端 未结 8 534
粉色の甜心
粉色の甜心 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:14

    You can use this hack:

    DateTime startDate = LogDate.Date;
    DateTime endDate = LogDate.Date.AddDays(1);
    
    var query = from t in context.Logs
                where t.Title == title 
                      && t.Timestamp >= startDate 
                      && t.Timestamp < endDate
                select t;
    

提交回复
热议问题