且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Linq获取项目数

更新时间:2023-11-26 13:53:34

您可以为此使用分组.请参阅: http://msdn.microsoft.com/en-us/library/bb896250.aspx [^ ]

例如:
You can use grouping for that. See: http://msdn.microsoft.com/en-us/library/bb896250.aspx[^]

For example:
var dataSource = (from t in context.Tags
                  group t by t.Description into t_group
                  select new
                  {
                        Name = t_group.Key,
                        Count = t_group.Count()
                  });