Simple way to return anonymous types (to make MVC using LINQ possible)

后端 未结 6 2011
囚心锁ツ
囚心锁ツ 2021-01-05 19:03

I\'d like to implement MVC while using LINQ (specifically, LINQ-to-entities). The way I would do this is have the Controller generate (or call something which generates) th

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-05 19:22

    Anonymous types are primarily designed to be used within a method. They are not suitable for communication between methods.

    If you need to pass a set of data between two functions the best way is to create a new type wrapping the data or use a loser grouping like Tuple or KeyValuePair

提交回复
热议问题