首页 > 其他 > 详细

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

时间:2018-04-18 19:59:18      阅读:616      评论:0      收藏:0      [点我收藏+]
var ShopList = ShopService.GetEntities(x => x.IsDelete == false).OrderByDescending(x => x.Sort).GroupBy(x => new
{
x.Id,
x.CityName
}).Select(x => new
{
//Id = x.Key.Id,
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

 

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

原文:https://www.cnblogs.com/SeNaiTes/p/8877097.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!