LINQ 客户端生成自增列

var testQuery = (from item in TestInfo.GroupBy(t=>t.TestName)
        select new 
    {
        TestCode = item.Min(g=>g.Code),
        TestName = item.Key
    }).OrderBy(t=>t.TestName).AsEnumerable();
    
    var testList = testQuery.Select((item,index)=>new
    {
        ID = index+1,
        TestCode = item.TestCode,
        TestName = item.TestName
    }).ToList();

 

posted on 2016-04-26 16:27  空明流光  阅读(1674)  评论(0编辑  收藏  举报

导航