已关闭。此问题需要超过focused。当前不接受答案。
**想要改进此问题吗?**更新此问题,使其仅关注editing this post的一个问题。
3天前关闭。
Improve this question
将此SQL查询转换为LINQ查询时,请获得帮助
SELECT EconCode.EconCodeId,
EconCode.EconCodeName,
EconCode.EconIncomeAmt,
EconCode.EconRecExpAmt,
EconCode.EconCapExpAmt,
FundCode.FundCodeId
FROM EconCode
LEFT OUTER JOIN FundCode
ON EconCode.FundCodeId = FundCode.FundCodeId
GROUP BY EconCode.EconCodeId,
EconCode.EconCodeName,
EconCode.EconIncomeAmt,
EconCode.EconRecExpAmt,
EconCode.EconCapExpAmt,
FundCode.FundCodeId
我以前尝试过以下代码,但在我的报告中没有显示任何内容。
var query = from econ in _context.EconCode
join fund in _context.FundCode on econ.FundCodeId equals fund.FundCodeId
group new { econ, fund.FundCodeId } by new { fund.FundCodeName, econ.FundCodeId, econ.EconCodeId, econ.EconCodeName, econ.EconIncomeAmt, econ.EconRecExpAmt, econ.EconCapExpAmt } into g
select new
{
fundcodeId = g.Key.FundCodeId,
fundCodeName = g.Key.FundCodeName,
econCodeId = g.Key.EconCodeId,
econCodeName = g.Key.EconCodeName,
econIncomeAmt = g.Key.EconIncomeAmt,
econRecExpAmt = g.Key.EconRecExpAmt,
econCapExpAmt = g.Key.EconCapExpAmt,
};
1条答案
按热度按时间anauzrmj1#
假设有两个名为EconCode和FundCode的对应实体类,上下文变量为dbContext,则提供的SQL查询的等效LINQ查询为: