How to write predicate for union join and inner queries?

I have a sql statement and I have to convert it into predicate to pass into a method.

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

my method call is like this. I tried many other way but not get success. :(

var resultList = someinstance.GetAll(
                    app=> app.IsSuspended = false)
                    .Union(someinstance.GetAll(
                    xap=>!xap.Id.Contains((xap.ApplicationAssociationId !=null).select(xap.Id)))
                    ).ToList();


Table Containing Data

enter image description here

Expected Result

enter image description here

Jon Skeet
people
quotationmark

It's not clear why you need a union at all here. Isn't it just an "or" condition?

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

(There's no need to check for IsSuspended being true in the second case, as if it's false it'll already be included in the first case.)

people

See more on this question at Stackoverflow