简体   繁体   中英

Linq query equivalent to sql

I have this code in Linq. Anybody can provide the t-sql. thanks!

var tsr = from t in db.Tngs
from l in t.TngUsr
from td in t.TngDepts
from u in db.Users
where t.TId == tId && u.UserId == l.UserId && u.Departments.DeptId == td.Departments.DeptId

is the second/third from left outer?

Try to run that in LinqPad . It would display the T-SQL equivalent of your linq code. It would even convert that linq expression into the equivalent Lambda expression.

It looks like it's something like this:

SELECT t, l, td, u
FROM Tngs
JOIN TngUser ON TngUser.UserID = Users.UserID
JOIN Users ON Users.UserID = TngUser.UserID
JOIN Departments ON DepartmentID = tngDepartmentID
WHERE Tngs.TId = tId

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM