我在 Linq 中有这段代码。任何人都可以提供 t-sql。谢谢!
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
从左外数第二个/第三个是?
我在 Linq 中有这段代码。任何人都可以提供 t-sql。谢谢!
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
从左外数第二个/第三个是?
尝试在LinqPad中运行它。它将显示您的 linq 代码的 T-SQL 等效项。它甚至会将该 linq 表达式转换为等效的 Lambda 表达式。
看起来是这样的:
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