在将ef core更新为3.0之后,如果尝试截断时间并仅比较日期时间中的日期,则ef core返回错误:
The LINQ expression 'Where<Category>(\n source: DbSet<Category>,\n predicate: (c) => c.CreateAt.Date == DateTime.Now.Date)' could not be translated. Either rewrite the query in a form that can be translated,or switch to client evaluation explicitly by inserting a call to either AsEnumerable(),AsAsyncEnumerable(),ToList(),or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
对于此查询:
Context.Category.Where(c => c.CreateAt.Date == DateTime.Now.Date).AsnoTracking().ToListAsync();
我只需要比较忽略DateTimeOffSet属性中时间的日期。