Is an EF query's null check performed on the db or webserver?

I'm using EF and Sql Server (CE). I'm trying to ensure as much as possible is run on the db. Consider this:

var data =
  getSomeEntities()
  .OrderBy(a => a.Date)
  .Select(a => new {
    Id    = a.Id,
    Name  = a.Name,
    Ref   = a.CustomerProfile != null ? a.CustomerProfile.Ref : null,     // ???
    Email = a.Email
  })
  .ToList();

Is the null check (the line marked with "???") executed on the db, or is materialized first and performed on the web server?

Also, I've noticed some of my code doesn't even perform that null check and works, and in some places if I don't do it then it throws. I wonder if it's even necessary?

Jon Skeet
people
quotationmark

That's performed in the database - if you add appropriate logging, you should see the appropriate SQL to get the right result.

In C# 6 you can just use

Ref = a.CustomerProfile?.Ref

people

See more on this question at Stackoverflow