Hello!
I have a model with nullable references to UserAuth. I would like to load this model with LoadSelect (Db.LoadSelect<DepartmentEntity>()
) and I noticed it’s generate unnecessary SQL select statements.
This is my model.
[Alias("Department")]
public class DepartmentEntity
{
[StringLength(250)]
public string Name { get; set; }
public string Description { get; set; }
[StringLength(254)]
public string Email { get; set; }
[References(typeof(UserAuth))]
public int? ManagerId { get; set; }
[Reference]
public UserAuth Manager { get; set; }
}
And here is the strange SQL statement if the ManagerId is null.
SELECT "Id", "UserName", "Email", "PrimaryEmail", "PhoneNumber", "FirstName", "LastName", "DisplayName", "Company", "BirthDate", "BirthDateRaw", "Address", "Address2", "City", "State", "Country", "Culture", "FullName", "Gender", "Language", "MailAddress", "Nickname", "PostalCode", "TimeZone", "Salt", "PasswordHash", "DigestHa1Hash", "Roles", "Permissions", "CreatedDate", "ModifiedDate", "InvalidLoginAttempts", "LastLoginAttempt", "LockedDate", "RecoveryToken", "RefId", "RefIdStr", "Meta" FROM "UserAuth" WHERE "Id"=NULL
Thanks,
Tom