How to use GroupBy using Dynamic LINQ

后端 未结 3 1999
清歌不尽
清歌不尽 2020-12-03 10:59

I am trying to do a GroupBy using Dynamic LINQ but have trouble getting it to work.

This is some sample code illustrating the problem:

List

        
3条回答
  •  孤城傲影
    2020-12-03 11:56

    This is the method I have copied from DynamicQuery:

    public static IQueryable GroupBy(this IQueryable source, string keySelector, string elementSelector, params object[] values) {..}
    

    In my example I provide the keySelector and the elementSelector.

    listAlbums.AsQueryable().GroupBy("it.Shop", "it").Select("Author"); You can use new with GroupBy or with select for the new types.

    It like this in OOP class.

提交回复
热议问题