gpt4 book ai didi

linq - 尝试将交叉连接 transact-sql 转换为 LINQ

转载 作者:行者123 更新时间:2023-12-04 06:15:56 25 4
gpt4 key购买 nike

我正在尝试解决这个交叉连接(我以前从未见过的东西),以便我可以转换为 LINQ。我不确定它要做什么:

Select various a,b,c,d, and e columns
From Fee a
inner Join FeeCategory b on a.CategoryID = b.FeeCategoryID
inner join FeeCompanyType c on a.FeeID = c.FeeID
cross join FeeType e
left outer join FeeTypeLink d on a.FeeID = d.FeeID and e.FeeTypeID = d.FeeTypeID


var q = (
from fees in Session.Query<Fee>()
join feeCategories in Session.Query<FeeCategory>() on fees.FeeCategory.Id equals feeCategories.Id
join feeCompanyType in Session.Query<FeeCompanyType>() on fees.Id equals feeCompanyType.Fee.Id
**erm.....**
)

大脑崩溃,任何帮助表示赞赏......

最佳答案

对于交叉连接,只需添加另一个 from :

from fees in Session.Query<Fee>()
//cross join:
from feetypes in Session.Query<Session.Query<Fee>()
join ...
join ...
// left join:
join feetypelink in Session.Query<FeeTypeLink>() on
new {fees.FeeID,feetypes.FeeTypeID} equals new{feetypelink.FeeID,feetypelink.FeeTypeID}
into gr
from res in gr.DefaultIfEmpty() .....

关于linq - 尝试将交叉连接 transact-sql 转换为 LINQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7244908/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com