How to return a generic list collection in C#?

前端 未结 5 1649
猫巷女王i
猫巷女王i 2021-01-13 01:16

I have some linq to sql method and when it does the query it returns some anonymous type.

I want to return that anonymous type back to my service layer to do some lo

5条回答
  •  既然无缘
    2021-01-13 01:38

    Anonymous types are very limited, you can only use them in the scope of the method were they are declared.

    You can pass them back as plain objects, but then you lose the type information. I have seen some solutions passing a anonymous type around; but they use reflection to retrieve the properties at a later point.

提交回复
热议问题