当前位置:   article > 正文

EF中GroupBy扩展方法的简单使用

eff groupby
 public ActionResult ShopInfo()
        {
            ViewBag.ShopList = ShopService.GetEntities(x => x.IsDelete == false).OrderByDescending(x => x.Sort).ToList();
            var ShopList = ShopService.GetEntities(x => x.IsDelete == false).GroupBy(x => new
            {
                x.CityName
            }).Select(x => new
            {
                Name = x.Key.CityName,
            }).ToList();

            string str = string.Empty;
            foreach (var item in ShopList)
            {
                str += ",'" + item.Name + "'";
            }
            ViewBag.Str = str.Substring(1);// 店名1,店名2,店名3
            return View();
        }

 

转载于:https://www.cnblogs.com/SeNaiTes/p/8877097.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/887100
推荐阅读
相关标签
  

闽ICP备14008679号