日期:2014-05-20 浏览次数:20951 次
using (studentEntities entities =new studentEntities()) { var item1 = (from c in entities.Score group c by c.ID into g select new { g.Key, g }); foreach (var m in item1) { if (m.Key == "11112") { foreach (var n in m.g) Console.WriteLine(n.ID + " " + n.course + " " + n.score1); } }
class Program { static void Main(string[] args) { using (studentEntities entities = new studentEntities()) { var v = from u in GetScore() group u by u.Num into g select new { Sss = g.Key, Mdd = g }; foreach (var m in v) { foreach(var n in m.Mdd) Console.WriteLine(n.Num + " " + n.Name + " " + n.Fen); } Console.ReadLine(); } } public static List<ScoreS> GetScore() { List<ScoreS> mylist = null; using (studentEntities entities = new studentEntities()) { var v = from u in entities.Score select new ScoreS { Num = u.ID, Name = u.course, Fen = u.score1 }; mylist = v.ToList(); } return mylist; } }