LINQ to Entities does not recognize the method 'System.TimeSpan Subtract(System.DateTime)

后端 未结 3 1791
北荒
北荒 2021-01-21 03:41

The following throws an error:

public FieldViewer GetFieldViewByFieldIDIPAndUserByDate( int fieldID, string ip, string userID, DateTime date )
{
    return this.         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-21 03:47

    Try this to find the difference in minutes:

    EntityFunctions.DiffMinutes(date, x.Viewer.CreatedAt) >= 10

    Sources:

    How to subtract EntityFunctions.TruncateTime from custom time

    EntityFunctions.DiffMinutes

    As this api is now obsolete (thanks for pointing this out @Jimmyt1988), instead use: DbFunctions.DiffMinutes

提交回复
热议问题