Presenting entity collection as System Collection?

Posts   
 
    
Posts: 14
Joined: 12-Oct-2004
# Posted on: 22-Nov-2004 16:58:53   

Hi,

How do I present an entirty collection as "System.Collection.IEmunerable" ?

I'm attempting to bind my DAL to a charting control (Dandas.Net), and the ADO.NET example they give is as follows:


Dim fileNameString As String = "chartdata.mdb"

' initialize a connection string. 
Dim myConnectionString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & fileNameString

' define the database query. 
Dim mySelectQuery As String = "SELECT * FROM CompanySales;"

' create a database connection object using the connection string. 
Dim myConnection As OleDbConnection = New OleDbConnection(myConnectionString)

' create a database command on the connection using query. 
Dim myCommand As OleDbCommand = New OleDbCommand(mySelectQuery, myConnection)

' open the connection. 
myCommand.Connection.Open()

' create a database reader.
Dim myReader As OleDbDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

' We optionally specify the Name column to be used for point's X values.
Chart1.DataBindTable(myReader, "Name")


When i try



Dim EntityCol As New DAL.CTMS.CollectionClasses.REF_PRODUCTSCollection
Dim Entity As New DAL.CTMS.EntityClasses.REF_PRODUCTSEntity
Dim sorter As SortExpression = New SortExpression
      sorter.Add(SortClauseFactory.Create(DAL.CTMS.REF_PRODUCTSFieldIndex.TITLE, SortOperator.Ascending))
EntityCol.GetMulti(Nothing, 0, sorter)

Chart1.DataBindTable(EntityCol.GetEnumerator(),"Title")

I just get a cast error. confused

I know EntityCol does contain the data I want, just not sure how to present the Entity object to the chart control.

Any ideas?

Many thanks Simon

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 22-Nov-2004 17:05:46   

I'm not familiar with the control but what overloads does Chart1.DataBindTable() have? The example you posted suggests the first parameter can be a datareader, but what can it be as well? An entity collection derives from CollectionBase, so you should be able to pass in the collection (I think)

Frans Bouma | Lead developer LLBLGen Pro