LINQ to SQL - Count of Columns in Result?

T

TisMe

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.
 
M

Marc Gravell

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top