• 普通
var list = from s in db.mm_ShopMas
                       where s.IsStop == false
                       group s by s.SpaceId;

   Sql执行时会取全部数据。

LinQ Group By

 

  • into
var list = from s in db.mm_ShopMas
                       where s.IsStop == false
                       group s by s.SpaceId into g
                       select g;

  Sql执行时会取全部数据。

LinQ Group By

  Select
  

var list = from s in db.mm_ShopMas
                       where s.IsStop == false
                       group s by s.SpaceId into g
                       select new { g.Key,Total = g.Count()};

 

  Sql执行的结果为汇总数据。

LinQ Group By

  • 多列Group
var list = from s in db.mm_ShopMas
                       where s.IsStop == false
                       group s by new { s.SpaceId ,s.TradeId} into g
                       select new { g.Key, Total = g.Count() };

  Sql执行结果为汇总数据。

 select new {g.Key.TradeId,g.Key.SpaceId,Tocal=g.Count()}

 LinQ Group By

select new {g.Key,Tocal=g.Count()}

LinQ Group By

  • 表达式

 

var list = from s in db.mm_ShopMas
                       where s.IsStop == false
                       group s by new { IdFirst = s.ShopId / 1000 } into g
                       select new { g.Key, Total = g.Count() };

Sql执行结果为汇总数据:

LinQ Group By

 

相关文章:

  • 2021-12-16
  • 2021-11-03
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-21
  • 2021-07-27
  • 2022-12-23
  • 2021-07-24
  • 2021-08-21
相关资源
相似解决方案