0
我有以下sql查詢,我無法將其轉換爲正確的linq語句。EF Linq無法將sql查詢轉換爲正確的linq
SELECT
r.RoleName,
uir.UserId
FROM
webpages_Roles r
LEFT JOIN webpages_UsersInRoles uir ON uir.RoleId = r.RoleId
AND r.AppId = 1
WHERE
uir.UserId IS NULL
在我的C#我有這樣的事情:
IEnumerable<Role> roles = uow.RolesRepository.Get(r => r.AppId == 1 && r.UsersInRoles.Any(uir => uir.UserId == null), includeProperties: "UsersInRoles");
我使用一個存儲庫,但它也可能是:
IEnumerable<Role> roles = context.Roles.Where(r => r.AppId == 1 && r.UsersInRoles.Any(uir => uir.UserId == null));
http://msdn.microsoft.com/en-us/library/vstudio/bb397895.aspx查看LEFT J OIN使用LINQ – LINQ2Vodka
構建您能提供樣本數據和期望的輸出嗎? – RedFilter