In ADO.Net/SQLClient I would often do something like this:
SELECT COUNT(*) FROM SomeTable WHERE SomeKey = 1234
…and fire it using executescalar to return the value of count – for a simple check if something exists.
How would I do the same using LinqToSql?
You could also use
Count().But this requires always to go through all rows while
Any()can return after the first matching row – soAny()might have better performance.