Can anyone advise on the LINQ equivalent of the below query please
Select staff.userStaffNo,userFirstName,userSurname,Resource.ResId, Resource.fkStaffStaffNo,userEmail from staff left outer join Resource on staff.userStaffNo = Resource.fkStaffStaffNo where ResID is NULL
First you can try the 2nd man's automatically code-converting tool, and then you can also try this:
var result = from item in xxx.Staffs
join r in xxx.Resource on item.No equals r.No into temp
from tr in temp.DefaultIfEmpty()
select new
{
Your fields here……………………
};
CSharper2012
Member
2 Points
17 Posts
SQL to LINQ
Dec 12, 2012 09:10 AM|LINK
Hi,
Can anyone advise on the LINQ equivalent of the below query please
Select staff.userStaffNo,userFirstName,userSurname,Resource.ResId, Resource.fkStaffStaffNo,userEmail from staff left outer join Resource on staff.userStaffNo = Resource.fkStaffStaffNo where ResID is NULL
me_ritz
Star
9337 Points
1447 Posts
Re: SQL to LINQ
Dec 12, 2012 09:13 AM|LINK
Use these tools to convert SQL to LINQ:
http://www.sqltolinq.com/
http://www.linqpad.net/
asteranup
All-Star
30184 Points
4906 Posts
Re: SQL to LINQ
Dec 12, 2012 09:15 AM|LINK
Hi,
You may check this-
http://msdn.microsoft.com/en-us/library/vstudio/bb397895.aspx
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: SQL to LINQ
Dec 13, 2012 12:35 AM|LINK
Hello,
First you can try the 2nd man's automatically code-converting tool, and then you can also try this:
var result = from item in xxx.Staffs join r in xxx.Resource on item.No equals r.No into temp from tr in temp.DefaultIfEmpty() select new { Your fields here…………………… };