WebMatrix queries support the new .Net Linq functionality. This allows you to apply Linq operators to your query results which makes it easy to get record counts. Example:
var db = Database.OpenFile("somedb.sdf");
var q1 = "select * from table";
There are a total number of @q1.Count() records in table.