The following simplified query (that has no real meaning) throws exception:
Code: Select all
from uu in DB.UserUsers
join uc in DB.UserConfigurations on uu.Id equals uc.Id_user
group uc.Config_key by uu.Id into grp
select new { IdUser = grp.Key, GroupCount = grp.Distinct().Count() }).ToList();
"Unknown column 't1.Id' in 'where clause'"
The problem is in DISTINCT() method. It works properly if it is omitted.
However, It should work with Distinct() method as well. Its MySql generated query could be like that:
Code: Select all
SELECT uu.id, COUNT(DISTINCT uc.Config_key)
FROM user_user uu JOIN user_configuration uc ON uu.id = uc.id_user
GROUP BY uu.id