我有3张桌子:
*USERS*
ID | USERNAME | ...
*SERVICE_NAME*
ID | SERVICE_NAME
*USER_SERVICES*
ID | ID_USER | ID_SERVICE
从表*USER_SERVICES*
,我可以检查用户是否启用了服务。
到目前为止,这是我的LINQ,但它只返回实际至少一个服务的用户。
var resultsServices = from p in USER_SERVICES
group p.ID_SERVICE by p.ID_USER into g
select new { ID_USER = g.Key, Services = g.ToList() };
users = (from user in USERS
join service in resultsServices on user.ID equals service.ID_USER
where user.ID == service.ID_USER
select new
{
user,
service.Services
});
我如何返回所有用户,即使他们没有启用任何“返回null”的服务?