.net core 左联接中所有数据为空时的Odata扩展问题

.net core 左联接中所有数据为空时的Odata扩展问题,.net-core,odata,webapi,.net Core,Odata,Webapi,我已经使用.NETCore实现了扩展ODataV4。它工作正常,但在expand中找不到键属性时会产生问题。 属性可为null,因此EF将对其应用左联接。为了确认这一点,我还检查了SQL profiler中的查询,并且该查询在SQL Server中也可以正常工作 如果我将所有属性作为select传递,那么它工作正常。让我们举一个例子 型号: Product{ public int prodid {get,set}; public string prodname {get,set}; public

我已经使用.NETCore实现了扩展ODataV4。它工作正常,但在expand中找不到键属性时会产生问题。 属性可为null,因此EF将对其应用左联接。为了确认这一点,我还检查了SQL profiler中的查询,并且该查询在SQL Server中也可以正常工作

如果我将所有属性作为select传递,那么它工作正常。让我们举一个例子

型号:

Product{
public int prodid {get,set};
public string prodname {get,set};
public string depid {get,set};
public Department department{get,set};
}

Department{
public string depid {get,set};
public string depname{get set}
}
工作扩展odata url:

http://localhost:5655/prod?$count=true$select=prodid$expand=department($select=depid,depname)
value:
{
       prodid:1
      Department:
      {
            depid:133
            depname:null
      }
}
http://localhost:5655/prod?$count=true$select=prodid$expand=department
Giving 500 internal server error
无法展开odata url:

http://localhost:5655/prod?$count=true$select=prodid$expand=department($select=depid,depname)
value:
{
       prodid:1
      Department:
      {
            depid:133
            depname:null
      }
}
http://localhost:5655/prod?$count=true$select=prodid$expand=department
Giving 500 internal server error
数据库中的数据:

Product table
prodid |depid |prodname
1      |133   |test

No data available in Department table for depid 133
在分析器中运行时,它正在生成以下查询:

select p.prodid,p.depid,t.depid, t.depname
from (select p.prodid,p.prodname from product p) as [p]
left join ( select d.depid, d.depname from department d) as [t] on p.depid=t.depid
result:
  prodid |p.depid |t.depid  |t.depname
  1      |133     |null     |null
请阅读-总结是,这不是一个理想的方式来解决志愿者,可能会适得其反获得答案。请不要将此添加到您的问题中。请阅读-总结是,这不是解决志愿者问题的理想方式,可能会对获得答案产生反作用。请不要将此添加到您的问题中。