SELECT COUNT(*) in LINQ
13 Dec 2010, 09:56
Subscribe to Richies blog (RSS)
Another short but sweet one:
This is pretty obvious, but I wasn't thinking straight this morning and it took a while.
To do the equivalent of an SQL SELECT COUNT(*) in LINQ, do this:
(from t in myTable where t.MyColumn == myVariable select t).Count();
Obviously, you can put whatever you like in the where clause, or remove it completely.
Comments | 1 |
Ratings | 80 |
Average rating | 100% |
Posted | 13 Dec 2010, 09:56 |
View blog | Richies blog |
Previous blog entry:
C# double question mark (??) syntax
Next blog entry:
Ctrl Alt Del in nested remote desktop
No comments have been made.