I have a domain class like below :

```
public class Employee
    {
        public int EmployeeId { get; set; }
        public int DeptId { get; set; }
    }

    public class Transaction 
    {
        public int TRID { get; set; }
        public int EmployeeId { get; set; }
        public string Status { get; set; }
    }

```

Now I want to get all employees from the EmployeeTable for DeptId = 100. I want to calculate Pending status for those employees whose transactions are pending.

So if employee records are found in Transactions table then just want to return a column saying whether employee has any pending transactions or not)

Query :

```
var t = (from e in _employeeRepository.GetAll() //returns IQueryable<Employee>
                                 where e.DeptId == 100
                                 from t in _transactionRepository.GetAll().Where(t => t.EmployeeId == e.EmployeeId)
                                 select new 
                                 {
                                    IsPendingTransaction = (t != null && t.Status != "Done") ? true : false,
                                 }).ToList();

```

> 
> Error : LINQ to Entities does not recognize the method
> 'System.Linq.IQueryable`1[Transaction] GetAll()' method, and this
> method cannot be translated into a store expression."}
> 
> 
> 

Sql Query :

```
SELECT e.*
(CASE WHEN (t.EmployeeId is not null and t.Status <> 'Done')
             THEN CAST(1 AS BIT) 
             ELSE CAST(0 AS BIT) 
        End) as IsPendingTransaction
FROM Employee e OUTER APPLY
     (SELECT t.*
      FROM Transactions t 
      WHERE e.EmployeeId = t.EmployeeId
     ) t
WHERE e.DeptId = 100;

```