如何使用Vb.net和C#实现Ef数据分组多字段查询?

2026-05-08 13:113阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计128个文字,预计阅读时间需要1分钟。

如何使用Vb.net和C#实现Ef数据分组多字段查询?

pythondef group_and_sum_data(data): grouped_data=data.groupby(lambda x: x['mName']).apply( lambda x: { 'mName': x['mName'].iloc[0], 'mPrice': x['mPrice'].iloc[0], 'mUnit': x['mUnit'].iloc[0], 'mValue': x['mValue'].sum() } ).reset_index(drop=True) return grouped_data

如何使用Vb.net和C#实现Ef数据分组多字段查询?

Dim g = lst.Data.GroupBy(Function(T) New With { T.mName, T.mUnit, T.mPrice }).Select(Function(t) New With { .mName = t.Key.mName, .mPrice = t.Key.mPrice, .mUnit = t.Key.mUnit, .mValue = t.Sum(Function(i) i.mValue) })

c#版本对照

{ var g = lst.Data.GroupBy(T => new { T.mName, T.mUnit, T.mPrice }).Select(t => new { mName = t.Key.mName, mPrice = t.Key.mPrice, mUnit = t.Key.mUnit, mValue = t.Sum(i => i.mValue) }); }

本文共计128个文字,预计阅读时间需要1分钟。

如何使用Vb.net和C#实现Ef数据分组多字段查询?

pythondef group_and_sum_data(data): grouped_data=data.groupby(lambda x: x['mName']).apply( lambda x: { 'mName': x['mName'].iloc[0], 'mPrice': x['mPrice'].iloc[0], 'mUnit': x['mUnit'].iloc[0], 'mValue': x['mValue'].sum() } ).reset_index(drop=True) return grouped_data

如何使用Vb.net和C#实现Ef数据分组多字段查询?

Dim g = lst.Data.GroupBy(Function(T) New With { T.mName, T.mUnit, T.mPrice }).Select(Function(t) New With { .mName = t.Key.mName, .mPrice = t.Key.mPrice, .mUnit = t.Key.mUnit, .mValue = t.Sum(Function(i) i.mValue) })

c#版本对照

{ var g = lst.Data.GroupBy(T => new { T.mName, T.mUnit, T.mPrice }).Select(t => new { mName = t.Key.mName, mPrice = t.Key.mPrice, mUnit = t.Key.mUnit, mValue = t.Sum(i => i.mValue) }); }