none
Linq to SPROC returning dynamic sql results with variable columns RRS feed

  • Question

  • Hi all,

    We have a SQL 2005 stored procedure that dynamically figures out column names then generates some dynamic sql to execute a pivot using those columns.   Depending on the data, we may have any number of columns returned.  

    Our data is stored in 4 columns; surveyid, questionid, answer, comment.  Our proc returns 1 row for each survey where the surveyid becomes a key and the answers and comments flattened into one row of repeating columns; SurveyID, Answer1, Comment1, Answer2, Comment2, Answer3, Comment3 etc...  We want to export this pivoted data as a spreadsheet.  The linq to spreadsheet part is done.

    We are having trouble getting the data back from linq because we aren't returning any particular type and everything we've read about linq and stored procedures relates to strongly typed data.  I'd be happy if we could get an anonymously typed var.

    We are still investigated doing the pivot in linq but the proc has already been written and is very fast so it would be nice to not have to redo that part.  

    Does anyone know how we'd get these variable column, untyped results back.  

    TIA
    Luke

    Monday, February 9, 2009 7:58 AM