score:-1

Try this. It may fail in case of database operations but for mockups it will do just fine because of concise operations.

flatLicenseOrderId = (from users in this.CustomerEntities.UserMappers
                                        .Where(x=>x.CompanyId==CompanyId && x.IsActive)
                      join order in this.CustomerEntities.Orders 
                           on users.customerid equals order.customerid 
                      into orderDetails
                      from customerOrder in orderDetails.DefaultIfEmpty()
                      join orderdetails in this.CustomerEntities.OrderDetails
                      on customerOrder?.OrderId equals orderdetails.OrderId
                      select new{users.customerid,orderdetails.OrderId})
                     .Distinct().ToList();

Related Articles