Home > database >  What can EF Core 5 translate
What can EF Core 5 translate

Time:11-07

I'm optimizing an expensive query, and have a hunch part of the problem is premature client side evaluation. I've searched around and am having a hard time finding a clear list of what can be translated into an SQL query for EF Core 5. These are the operations I'm specifically wondering about:

.Where(entity => listOfInts.Contains(entity.Id))
.Where(entity => entity.SomeStringProp.Contains("SomeSubsString")
.Where(entity => entity.SomeNullableProp.HasValue)

I'm no SQL expert but I could imagine these being feasibly translatable. I just don't know if EF Core 5 is as smart as I hope it is. Any pointer to documentation on this is appreciated.

CodePudding user response:

EF Core 5 does not have automatic client side evaluation (EF before 3 though did) So unless you explicitly evaluate on client side (via AsEnumerable or ToList and their async counterparts) your query should be translated into SQL (with small exclusion of final projection).

Also since you are trying to figure out performance of your query - try checking out the SQL generated by EF. Since 5.0 you can use EntityFrameworkQueryableExtensions.ToQuery to see it (and depending on the database - using profiler or database pesific queeries/logs).

  • Related