EFCore 2.1 and Pomelo MySql - Left Join LINQ Query Not working

538 views Asked by At

I have two tables with the following relationship: "Order" having one to many relationship with "OrderTasks"

I am trying to run the following SQL statement through LINQ:

    SELECT o.*
    FROM `Order` AS `o`
    LEFT JOIN `OrderTask` AS `t` ON `o`.`Id` = `t`.`OrderId`
    where t.Id is null

According to the MS Docs, this is supposed to be the LINQ query:

IQueryable<Order> orders = from o in _context.Orders
                                       join t in _context.OrderTasks
                                           on o.Id equals t.OrderId into grouping
                                       from t in grouping.DefaultIfEmpty()
                                       select o;

But it is generating the below:

   SELECT `o`.*
   FROM `Order` AS `o`

I am using EFCore 2.1 and Pomelo Mysql provider against mysql version 5.6. Any idea what needs to be adjusted to get the left join working? Thank you in advance!

0

There are 0 answers