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

标签 c# linq translation linq-query-syntax

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

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/

相关文章:

ruby-on-rails - ActiveRecord Transaction并返回模型保存的id

c# - 如何检查元素标签是否为结束元素

c# - Windows Phone PhoneGap 应用程序不应可缩放

c# - 页面源码怎么能省略某些东西

c# - 将默认 where 子句添加到 linq-to-sql 表

Django 翻译 : add custom translation

Symfony - Sonata-管理菜单组翻译

c# - 在单元测试中获取命令行参数

c# - 使用 lambda 从嵌套列表中分离值

如果属性在 List<string> 中,C# 从 List<T> 中删除所有项目