I have an ASP.Net Core API that must run with both a Sql Server and Sqlite connection depending on the client setup. I have several instances in my application where I am doing Left Outer Joins with Linq. I based these left outer joins off of the answer by Stefan Steiger in this question.
The queries run just fine when connceted to Sql Server, however when run in Sqlite, I get a warning saying the query will be evaluated locally, and a noticable performance hit.
For example, given the following scenario where I have an Ord record, that might have an active Odt record associated with it. I have a query that looks like this:
var test = await (from order in _context.Ord.AsNoTracking()
from activeOdt in _context.Odt.AsNoTracking()
.Where(x => x.Active)
.DefaultIfEmpty()
select new { order, activeOdt }
).ToListAsync();
In Sqlite only, I get the following warning:
warn: Microsoft.EntityFrameworkCore.Query[20500] The LINQ expression 'from Odt activeOdt in {from Odt x in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Smart.Common.Odt]) where (([x].OrdId == [order].Id) AndAlso [x].Active) select [x] => DefaultIfEmpty()}' could not be translated and will be evaluated locally.
Am I somehow writing this query incorrectly? Do I need to handle it differently in Sqlite, or is this perhaps some kind of Sqlite limitation with Entity Framework?