How to use the Count aggregate function with VB9?

Can someone please provide me with a little sample for using the count aggregate function with select. I tried the following but got an 'count not declared" compile error:

Dim AuthorsCount = Select Count(Author) From Author In AllAuthors Where Author.AuthorSince > "1.1.2005"

Class Author
Public Name As String
Public AuthorSince As Date
End Class

Dim AllAuthors = New Author() {Au1, Au2, Au3}

Dim Au1 As Author = {Name := "Peter", AuthorSince:= "1.4.2004"}
etc

When I declare AllAuthors As Integer I got a type conversion error because AllAuthors Is not of IEnumerable(Of Author) which means that Count is not recognized as a function name?

Thanks,
Peter

[726 byte] By [PeterM] at [2008-2-14]
# 1
Hi Peter,

You are trying to use the form of SQL-style aggregation that is not yet implemented.

In this case you would import the System.Query.Sequence class in which Count is defined and write

Dim AuthorsCount = _
Count(Select Author _
From Author In AllAuthors _
Where Author.AuthorSince > "1.1.2005")

Hope this helps,

Erik

ErikMeijer at 2007-9-9 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...

Visual Studio Orcas

Site Classified