tags:

views:

274

answers:

2

I have a database table which could contain many records and I'd like to count the current total in the table. I was going to do a simple:

DataContext.Table.Count(c => c.condition);

Until I realized the return type for Count is int. What if the table is to hold more values than can be represented in 32 bits? How can I count them?

Should I be counting them in a different way when we're talking about that kind of scale?

+1  A: 

My solution was to use the .LongCount() extension method.

Martin
Don't use answers to reply to other posters. Use comments or edit your question. This is not a discussion forum.
Geoffrey Chetwood
It sounded to me like he found the answer himself and posted it, rather than replying.
Mark Pattison
@Mark: His original post was an apology for not finding it. I have edited it.
Geoffrey Chetwood
I wasn't replying to other posters btw, I was replying to my own question - but yes I did also apologise for not looking harder before I left the original question. It made less sense to edit my question with an answer than to answer it.
Martin
+8  A: 

Use LongCount(), same thing but with a 64 bit result.

Chris Shaffer