LINQ to SQL - Count of Columns in Result?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TisMe

    #1

    LINQ to SQL - Count of Columns in Result?

    Hi All,

    Does anyone know of a way to count the number of columnns in a
    Linq2SQL result? (In this case ISingleResult).

    I am building a method to get summary report data. I want to be able
    to add a column to my stored procedure at some point, without amending
    the clientside code where the data is displayed in a gridview,
    populated from a datatable - I want to define the columns in the
    datatable dynamically, looping X number of columns in the LINQ result.

    Hope that makes sense!

    Thanks.
  • Marc Gravell

    #2
    Re: LINQ to SQL - Count of Columns in Result?

    It seems to me that executing an arbitrary query where you don't know
    the output schema is not the intended use-case for LINQ-to-SQL. Perhaps
    just execute this via SqlCommand and your choice of SqlDataReader /
    DataTable?

    There is no benefit from fighting the system, just to use LINQ-to-SQL in
    a case when it doesn't help you...

    Marc

    Comment

    Working...