System.InvalidOperationException: The binary operator NotEqual is not defined for the types 'Microsoft.EntityFrameworkCore.Storage.ValueBuffer' and 'Microsoft.EntityFrameworkCore.Storage.ValueBuffer'.


  .netcore 2.1使用左表连接时报错,原因是对数据库中实体 DateTimeOffset date做查询判断时,将数据库中date转为string进行了判断,这样判断是错误的,并且效率低,应该是不改变数据库中字段类型,将查询条件字段更改为数据库字段类型

  错误的写法:

 var _upTwoLst = _postgreDbContext.income.Where(m=>m.date.Date.ToString("yyyy-MM-dd") == DateTimeOffset.Now.AddDays(-1).ToString("yyyy-MM-dd"));

  正确的写法:

 var _upTwoLst = _postgreDbContext.income.Where(m=>m.date== DateTimeOffset.Parse(DateTimeOffset.Now.AddDays(-2).ToString("yyyy-MM-dd")));

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM