Billpeng Space

技术源自生活
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

linq lambda操作list的例子

Posted on 2012-09-12 17:15  billpeng  阅读(200)  评论(0编辑  收藏  举报
        var foodmylist = Bangso.MethodUtility.FillEntity.GetListFromSqlcmd<Bangso.Module.FoodMy>(sqlcmd, param2);
        var s = (from un in foodmylist where un.Username == "xinux" select un).ToList() ;
        var s2 = from fm in foodmylist group fm by new { fm.Datetime, fm.Username } into g select new {lear = g.Key,cc =g.Count()};
        var s3 = foodmylist.GroupBy(fm => new { fm.Datetime, fm.Username }).Select(g => new{Lear = g.Key,cc = g.Count()});
        foreach (var temps in s)
        {
            context.Response.Write(temps.Title);
        }