I have an sql statement that I'd like to return a list of Persons that have a related Department entity. The Person class has a Department ID and with the magic of entity framework it associates the correct Department object when I load it from the database.
My SQL statement is:
SELECT *
FROM PERSON
INNER JOIN DEPARTMENT ON PERSON.DEPARTMENT_ID = DEPARTMENT.ID
WHERE UPPER(FORENAME) LIKE '%RALPH%'
ORDER BY SURNAME
In MSSMS when I run the query I get the following results:
However, when I run the sql using DbSet.SqlQuery() I get the following results:
Note how the department object is null in the first item, yet has been populated in the second item.
I know I haven't provided much information, I'm hoping there's just a simple answer for this.
By the way..
DataContext.Configuration.LazyLoadingEnabled = false;
LazyLoadingEnabled is set to false as you can see, I know changing this to true would fix the issue. I'd just rather not go enabling it for whichever call I fancy needs it.
Thanks guys


SqlQueryand not a proper EF query?