gpt4 book ai didi

c# - GroupBy 与 linq 方法语法(不是查询语法)

转载 作者:IT王子 更新时间:2023-10-29 04:42:23 25 4
gpt4 key购买 nike

如果我使用扩展方法语法,下面的查询会是什么样子?

var query = from c in checks
group c by string.Format("{0} - {1}", c.CustomerId, c.CustomerName)
into customerGroups
select new { Customer = customerGroups.Key, Payments = customerGroups }

最佳答案

看起来像这样:

var query = checks
.GroupBy(c => string.Format("{0} - {1}", c.CustomerId, c.CustomerName))
.Select (g => new { Customer = g.Key, Payments = g });

关于c# - GroupBy 与 linq 方法语法(不是查询语法),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/967099/

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