GroupBy with linq method syntax (not query syntax)

前端 未结 4 1600
悲&欢浪女
悲&欢浪女 2021-01-03 23:18

How would the following query look if I was using the extension method syntax?

var query = from c in checks
group c by string.Format(\"{0} - {1}\", c.Custome         


        
4条回答
  •  清酒与你
    2021-01-03 23:35

    It would look like this:

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

提交回复
热议问题