Sunday, August 22, 2010

Webrazor Newbie Tip: Getting a Record Count

OK, a common task is getting record counts. With WebMatrix, you return a query that actually is a bunch of objects that are IEnumerable. If you are a noob don't worry to much about what they means so much as what it allows you to do.

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.




Easy.

1 comment:

Anonymous said...

thanks, i was exactlly looking for that :)