简体   繁体   中英

Get data from Stored Procedure without knowing the amount of columns

I am making a web application in ASP.NET using C# and LINQ.

I have made a stored procedure which converts my result set into a pivot table and returns the 'pivoted' result.

How can I select this result in my LINQ statement and attach this to my datagridview?

for example:

NUMBER     QUESTION               ANSWER
1          How old are you        15
1          Where do you live      Belgium
1          What's your name       Dennis
2          How old are you        19
2          Where do you live      Germany
2          What's your name       Tom
3          How old are you        26
3          Where do you live      Holland
3          What's your name       Gary

Becomes:

NUMBER       How old are you       Where do you live       What's your name
1            15                    Belgium                 Dennis 
2            19                    Germany                 Tom
3            26                    Holland                 Gary

Thanks

you cannot make this using LINQ. And in this case I don't think you actyally need it. Just make the data transformations inside your app, not in the stored proc. If anyway you think that this is the only possible way to work with your data, I would recommend to use low level SqlClient approach ( here for example)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM