return list with anonymous type in entity framework

后端 未结 6 1499
北恋
北恋 2021-01-02 07:21

How i can return list with anonymous type, because with this code i get

\"The type or namespace name \'T\' could not be found (are you missing a using directive or a

6条回答
  •  梦毁少年i
    2021-01-02 07:58

    The class Tuple<> is made for situations like this. Creating a custom class as already suggested is clearer, but Tupple gets the job done too.

    e.g.

    .Select(row => new Tuple(row.IdMember,row.Profile_Information.UserName))
    

    to access the member properties at the other side of the wire, you'll need to use:

    var id=t.Item1
    var name=t.Item2
    

提交回复
热议问题