I'm having trouble with Entity Framework Plus. I can't seem to get the loading of multiple levels working.
The following query works fine. I get the user back with the expected list of addresses.
var user = _dataContext.Users
.Where(u => u.UserName == username)
.IncludeFilter(u => u.Addresses.Where(a => !a.Deactivated.HasValue))
.SingleOrDefault();
But the following query causes it to fall apart.
var user = _dataContext.Users
.Where(u => u.UserName == username)
.IncludeFilter(u => u.Addresses.Where(a => !a.Deactivated.HasValue).Select(a => a.AddressType))
.SingleOrDefault();
I get the user back, but now my list of Addresses is empty.
I'm using EF6 and EF+ v1.7.14.0
Thanks in advance to anyone who can help.
Cheers Craig
Arrgh! What a dope! I need to do it in two statements... which makes perfect sense really. I was selecting out the address type and leaving the address behind.
My query needs to be as follows:
var user = _dataContext.Users
.Where(u => u.UserName == username)
.IncludeFilter(u => u.Addresses.Where(a => !a.Deactivated.HasValue))
.IncludeFilter(u => u.Addresses.Where(a => !a.Deactivated.HasValue).Select(a => a.AddressType))
.SingleOrDefault();
Thanks me. You're a champ!