zoukankan      html  css  js  c++  java
  • C# GroupBy的使用

    var skill = query.GroupBy(i=>i.SkillTypeId)
    .Select(i => new
                {
                  skillType=i.key,
                  skill=i.Select(s=>new{
                  i.Id,
                  i.Level,
                  i.IsEquiped,
                })                          
     

    输出结果

    {
    "skillType":“刀”
    "skill": [
                    {
                        "Id": 35,                                                     
                        "Level": 1,                  
                        "IsEquiped": true,                   
                    },
                    {
                        "Id": 36,                   
                        "Level": 1,
                        "IsEquiped": true,
                      
                    },
         ]
    "skillType":""
    "skill": [
                    {
                        "Id": 35,                                                     
                        "Level": 1,                  
                        "IsEquiped": true,                   
                    },
                    {
                        "Id": 36,                   
                        "Level": 1,
                        "IsEquiped": true,
                      
                    },
         ]
    }

    转自:https://blog.csdn.net/hhhhhhenrik/article/details/81980594?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

  • 相关阅读:
    菜根谭#308
    菜根谭#307
    菜根谭#306
    菜根谭#305
    菜根谭#304
    菜根谭#303
    菜根谭#302
    菜根谭#301
    菜根谭#300
    菜根谭#299
  • 原文地址:https://www.cnblogs.com/firstcsharp/p/12384941.html
Copyright © 2011-2022 走看看