Domanda

Hoping someone can help me out with what is probably a dumb question.

I'm trying to use a datarepeater to display data generated via LINQ from a datatable

I've managed to do this fine with a filtered existing datasource using:

Me.Tbl_52TableAdapter.Fill(Me.CBRDataSet.tbl_52)

Dim query =
  From dlist In CBRDataSet.tbl_52.AsEnumerable
  Where (dlist.Field(Of String)("TL") = "CTS 06")
  Select dlist

query.CopyToDataTable().AsDataView()
DataRepeater1.DataSource = query

The problem being that I need to aggregate a field in the dataset into a count.

If I replace the query with:

Dim query =
  From CountAgent In CBRDataSet.tbl_52.AsEnumerable
  Group CountAgent By PBX = CountAgent.Field(Of String)("TL") Into Count()
  Select Count

It then states that: 'CopyToDataTable' is not a member of 'System.Collections.Generic.IEnumerable(Of Integer)'

I've tried to get around it by changing the declaration to: Dim query As IEnumerable(Of DataRow) =

Which compiles, but I have no idea if it works, and I cant check as I can't find a way to bind a label to the produced count col of the dataview.

If anyone can tell me what I'm doing wrong i'd be most appreciative.

È stato utile?

Soluzione

Coming back to my own question, in case it helps anyone else: MSDN had the answer - You need to overload copyToDataTable as described in

"How to: Implement CopyToDataTable Where the Generic Type T Is Not a DataRow" on:

http://msdn.microsoft.com/en-us/library/bb669096.aspx

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top