I have an SQL query which returns all accounts and in the top of the result table I have accounts which share same documents. Query below works just fine, but there is a problem implementing the same logic on linq.
select
(
select
COUNT(*)
from Signs X, Signs Y
where X.AccountID = 2 and Y.AccountID = A.ID and X.DocID = Y.DocID
),
*
from
Accounts A
where
A.ID != 2
order by 1 desc
Note: You could probably change the subquery to a join on
DocIDbut i’ve left as is, so you can see the similarity between the SQL and the LINQ.Example with a join: