0
select    
  count(di.field1) as myCount,
  di.field2
  from di
group by  di.field2

我试图理解这个概念:

 group di.field2 by new { di.field1, di.field2 } into g
       select new
          {
             documentID = g.Key.field2,
             docCount = g.Count(????)
          });

我如何获得 field1 计数的值?

4

3 回答 3

1

也许是这样的:

group di by di.field2 into g
       select new
          {
             documentID = g.Key,
             docCount = g.Select(c => c.field1).Count()
          });
于 2013-02-19T18:03:40.443 回答
1
    from p in di
    group p by p.field2 into g 
    select new { field2 = g.Key, field2Count = g.Count() };

检查这个。,这应该工作

于 2013-02-19T18:09:19.267 回答
0

您是否需要进行分组以获得字段计数?你不能这样做:

var count=di.field1.Count;
于 2013-02-19T17:56:15.483 回答