How to return a generic list collection in C#?

前端 未结 5 1614
猫巷女王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:31

    You want to return an anonymous type from a regular method? I'm quite sure you can with Reflection, but there would be no type safety and a whole host of other problems. Not to mention it looks weird from the calling codes perspective. You would basically have to return object I think.

    You would be better use a class or struct and stuff the values in there.

提交回复
热议问题