Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.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# 如何为联合联接和内部查询编写谓词?_C#_.net_Linq_Predicate - Fatal编程技术网

C# 如何为联合联接和内部查询编写谓词?

C# 如何为联合联接和内部查询编写谓词?,c#,.net,linq,predicate,C#,.net,Linq,Predicate,我有一个sql语句,必须将其转换为谓词才能传递到方法中 select * from applications where IsSuspended = 0 union select * from Applications where id not in (select ApplicationAssociationId from Applications where ApplicationAssociationId is not NULL ) and IsSuspended = 1 我的方法调

我有一个sql语句,必须将其转换为谓词才能传递到方法中

select * from applications
where IsSuspended = 0 
union
select * from Applications where
id not in 
(select ApplicationAssociationId from Applications where ApplicationAssociationId is not NULL )
and IsSuspended = 1
我的方法调用是这样的。我尝试了许多其他的方法,但没有成功(


包含数据的表



预期结果


现在还不清楚你为什么需要一个工会。这不只是一个“或”条件吗

var query = applications.Where(
     x => !x.IsSuspended ||
          !applications.Any(y => x.Id == y.ApplicationAssociationId));
(在第二种情况下,不需要检查IsSuspended是否为true,就好像它是false一样,它已经包含在第一种情况中。)

var query = applications.Where(
     x => !x.IsSuspended ||
          !applications.Any(y => x.Id == y.ApplicationAssociationId));