我想替换这个 SQL 命令:
string dotazBankUcty = @"SELECT
H.UCET,
SUM(H.KON_STAV_MD) AS KON_STAV_MD,
SUM(H.KON_STAV_DAL) AS KON_STAV_DAL ,
SUM(H.KON_STAV_MD_MENA) AS KON_STAV_MD_MENA,
SUM(H.KON_STAV_DAL_MENA) AS KON_STAV_DAL_MENA,
MAX(UBUC.KOD_MENY) AS KOD_MENY
FROM UHLAVAKT H
inner join UBUC on H.UCET = UBUC.UCET GROUP BY H.UCET";
使用 LINQ 命令。我试过这个,但它返回一个左连接而不是我想要的内连接。
var uhlavAktQuery = new XPQuery<UHLAVAKT>(CoreHelper.DataSession);
var ubucQuery = new XPQuery<UBUC>(CoreHelper.DataSession);
var resultBankyUcty = (from h in uhlavAktQuery
join u in ubucQuery on h.CompoundKey1.UCET equals u.UCET
group new { h, u } by new { h.CompoundKey1.UCET } into gUcty
select new
{
Ucet = gUcty.Key.UCET,
KON_STAV_MD = gUcty.Sum(k => k.h.KONSTAVMD),
KON_STAV_DAL = gUcty.Sum(k => k.h.KONSTAVDAL),
KON_STAV_MD_MENA = gUcty.Sum(k => k.h.KONSTAVMDMENA),
KON_STAV_DAL_MENA = gUcty.Sum(k => k.h.KONSTAVDALMENA),
KOD_MENY = gUcty.Max(k => k.u.KODMENY)
});
你能帮我吗?