Entity Framework查询的奇怪行为

时间:2021-09-09 02:13:40

Below query yielded no results even when there was matching record in the DB. Entity Framework查询的奇怪行为

即使数据库中存在匹配记录,下面的查询也没有产生任何结果。

  • Even the query generated will yield the result when executed in DB.
  • 甚至生成的查询也会在DB中执行时产生结果。

  • Also, query yields the result when "order by" is added to the query.
  • 此外,查询会在将“order by”添加到查询时生成结果。

  • No changes in the query parameters.
  • 查询参数没有变化。

  • Same query works for dev database, yields no result in QA database.
  • 相同的查询适用于dev数据库,在QA数据库中不会产生任何结果。

  • There is no change in the QA database compared to Dev.
  • 与Dev相比,QA数据库没有变化。

Entity Framework查询的奇怪行为

1 个解决方案

#1


0  

I think you need to add filter for the ADMINGROUP

我认为您需要为ADMINGROUP添加过滤器

var currentDept = (from d in dbContext.TBLZLISTDEPTs
where d.ADMINGROUP != null
select new 
{
   d.ADMINGROUP
}).FirstOrDefault();

#1


0  

I think you need to add filter for the ADMINGROUP

我认为您需要为ADMINGROUP添加过滤器

var currentDept = (from d in dbContext.TBLZLISTDEPTs
where d.ADMINGROUP != null
select new 
{
   d.ADMINGROUP
}).FirstOrDefault();