Linq to sql - GroupBy

View Code
  protected IList<String> SelectTitleList()
        {
             using (SamjinDBDataContext db =  new SamjinDBDataContext())
            {
                IList<String> returnList =  new List<String>();

                 var list =  from v  in db.View_Design_History
                           group v by v.Title into g
                            select  new { 
                                //  g.key 是 v.Title 值 
                                        Title = g.Key
                            };
                 foreach ( var item  in list)
                {
                    returnList.Add(item.Title);
                }
                 return returnList;
            }
        }

你可能感兴趣的:(group)