LINQ Custom Sort

后端 未结 3 1060
后悔当初
后悔当初 2020-11-30 11:51

I want an alphabetic sort with one exception.
There is a Group with a Name = \"Public\" and an ID = \"0\" that I want first.
(would rather use ID = 0)
After that

3条回答
  •  误落风尘
    2020-11-30 12:37

        public IEnumerable GroupAuthoritysSorted 
        { 
            get 
            { 
                return GroupAuthoritys.OrderBy(x => x.Group.ID == 0)
                                      .ThenBy(x => x.Group.Name); 
            } 
        }
    

提交回复
热议问题