Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# LINQ查询左联接多个列,空检查失败_C#_Postgresql_Entity Framework_Linq_Asp.net Core - Fatal编程技术网

C# LINQ查询左联接多个列,空检查失败

C# LINQ查询左联接多个列,空检查失败,c#,postgresql,entity-framework,linq,asp.net-core,C#,Postgresql,Entity Framework,Linq,Asp.net Core,pt和emod都是内存查询,返回teleentrowvaluesdbmodel类型。在显示此语句之前,这两个命令都不会执行 如果我分别调试并查看返回的结果,则会成功运行并返回值 我可以在子查询中使用除之外的或不使用吗!,但我只是想了解这是一个bug还是有解决方法 奇怪的是,如果我删除对tempe对象的任何引用,一切都正常运行。 我错过什么了吗 var RealNewNodes = from p in pt join e1 in emod on new{X1

pt
emod
都是内存查询,返回
teleentrowvaluesdbmodel
类型。在显示此语句之前,这两个命令都不会执行

如果我分别调试并查看返回的结果,则会成功运行并返回值

我可以在子查询中使用除之外的或不使用吗!,但我只是想了解这是一个bug还是有解决方法

奇怪的是,如果我删除对
tempe
对象的任何引用,一切都正常运行。 我错过什么了吗

var RealNewNodes = from p in pt
                   join e1 in emod on new{X1 = p.tElementRowsDBModelID, X2 = p.tAttributesDBModelID, X3 = p.AttributeValue} equals new {X1 = e1.tElementRowsDBModelID, X2 = e1.tAttributesDBModelID, X3 = e1.AttributeValue } into tempt
                   from tempe in tempt.DefaultIfEmpty() 
                   where tempe == null //if i remove this line, works OK
                   select new tElementRowValuesDBModel{
                       tElementRowsDBModelID = p.tElementRowsDBModelID,
                       tAttributesDBModelID = p.tAttributesDBModelID,
                       AttributeValue = p.AttributeValue,
                       ID = (tempe!=null ? 1 : 0 )//if i remove this line, works OK
                   };

也许如果您没有进行连接,因为您的
join
/
where
意味着查找
pt
而不匹配,它将起作用:

var RealNewNodes = from p in pt
               where !emod.Any(e1 => p.tElementRowsDBModelID == e1.tElementRowsDBModelID && p.tAttributesDBModelID == e1.tAttributesDBModelID && p.AttributeValue == e1.AttributeValue)
               select new tElementRowValuesDBModel {
                   tElementRowsDBModelID = p.tElementRowsDBModelID,
                   tAttributesDBModelID = p.tAttributesDBModelID,
                   AttributeValue = p.AttributeValue,
                   ID = 1
               };

它以什么方式失败?@RomanoZumbéobject reference未设置为objectIs this EF Core的实例?如果是,什么版本?@IvanStoev Hi csproj文件中的引用指向1.1。*有/有许多EF Core bug与
左外连接相关,您可能会检查他们的问题跟踪程序,或者尝试是否发生在最新和最伟大的版本(目前为v1.1.2版)谢谢,还没有尝试过,我会尽快告诉你这是否有效我发誓。。。我刚刚重新启动了我的电脑,我原来的问题现在可以解决了。。。然而,这个答案也提供了同样的结果。谢谢