Asp.net 我想将SQL转换为Linq查询。下面给出了sql查询
我对林克比较陌生。但我会这样做Asp.net 我想将SQL转换为Linq查询。下面给出了sql查询,asp.net,linq,Asp.net,Linq,我对林克比较陌生。但我会这样做 select * from HrNotifications n where HrmEmployeeId not in (select HrmemployeeId from HrNotificationViewEmployees where HrmEmployeeId = n.HrmemployeeId
select *
from HrNotifications n
where HrmEmployeeId not in (select HrmemployeeId
from HrNotificationViewEmployees
where HrmEmployeeId = n.HrmemployeeId
and HrNotificationId = n.Id)
让我们看看您尝试了什么—您可以显示表结构—请不要只是发布SQL并要求转换。至少显示一个类模型,以便导航属性和关联的多样性可见。另外,告诉你的目标是什么类型的LINQ(对实体?),并展示你自己的第一次努力。他们向我们澄清的比你想象的要多。
var innerquery=HrNotifications.join(HrNotificationViewEmployees,c=>c.Id,ca=>ca.HrNotificationId,(c,ca)=>new{HrNotifications=c,HrNotificationViewEmployees=ca}).select(s=>s.HrNotificationViewEmployees.HrmemployeeId).ToList();
var result=HrNotifications.where(s=>!innerquery.Contains(s.HrmEmployeeId));
var NotifyAnnouncementEmp = (from Ntfy in dbContext.NotificationDbSet
where !dbContext.NotificationViewEmployeeDbSet.Where(w => w.HrmEmployeeId == EmpId && w.HrNotificationId==Ntfy.Id).Select(s => s.HrmEmployeeId).ToList().Contains(EmpId) && Ntfy.HrmEmployeeId==EmpId
select new
{
Ntfy.Id,
Ntfy.MessageSubject,
Ntfy.Message
}).ToList();