gpt4 book ai didi

c# - 如何在 C# Linq 中编写这个

转载 作者:太空狗 更新时间:2023-10-30 00:43:53 25 4
gpt4 key购买 nike

我不是 Linq 的专家,但正在尝试理解。如何用 C# 编写此代码(用 VB 编写)

Dim x = From p in db.YourClass _

Where p.fl1 = cn1 And p.f12 = cn2

Select _

sum1 = x.Sum(Function(y) y.fl1), _

sum2 = x.Sum(Function(y) y.fl2), _

sum3 = x.Sum(Function(y) y.fl3)

我想实现的是这个,

select sum(fl1),sum(fl2),sum(fl3)

where fl1 =cn1 and fl2=cn2

The above sample found here

最佳答案

var x =
from p in db.YourClass
where p.fl1 == cn1 && p.fl2 == cn2
select p;


var sum1 = x.Sum(y => t.fl1);
var sum2 = x.Sum(y => t.fl2);
var sum3 = x.Sum(y => t.fl3);

关于c# - 如何在 C# Linq 中编写这个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9409528/

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