typedlist to entity collection or IEnumberable

Posts   
 
    
Jeff
User
Posts: 13
Joined: 28-Aug-2003
# Posted on: 04-Feb-2005 05:37:20   

I have a custom databound web control that was built a while back. Its a custom control that binds directly to an EntityCollection and displays some fields (X,Y,Z) for each row in the collection . We are having some performance issues becuase the table has like 50 columns now and with EntityCollection we bring back all columns. This control which i did not create, stores the datasource in viewstate (yeah, i know bad... but i don't have time to go and refactor all this right now). So I converted this to use a typedlist (which btw, creating typed lists from code rocks....) but now i broke the contract between my custom control and the datasource since the only common interface between datatable and entity collection that i can see is IListSource which does not seem to help me much. What is the easist way to convert a TypedList to an EntityCollection or an IEnumberable? basically i want to be able to set my TypedList to the DataSource property of my control so i can still do native binding. One way i can think of is manually convert the typed list to a custom IEnumberable or something, will this work, i assume i will still need to use the necessary field names. EntityCollection is basically a collection implimenting IEnumerable right? Or is there a native llblgen way to do this? hopefully this is understandable. I am using Self Servicing if that matters.

Thanks.

can someone also tell me why datatable does not impliment IEnumerable, there must be a reason and i dont know what it is due to my lack of knowlege.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 04-Feb-2005 10:44:04   

How do you pass the entity collection to the control? Because if you do that via a property or method call, you have to pass in an entitycollection implementing object, so a typed list/datatable is not going to work, OR you have to refactor the interface, which would solve the problem also.

(I'm not sure why teh datatable doesn't implement IEnumerable, a dataview does btw.

Frans Bouma | Lead developer LLBLGen Pro
Jeff
User
Posts: 13
Joined: 28-Aug-2003
# Posted on: 04-Feb-2005 15:14:25   

This is exactly how i am doing it, something like MyContol.DataSource = myEntityCollection.

So, it seems i need to manually convert my typed list to an IEnumberable or something? Anyone have a sample of how to do this?

Otis wrote:

How do you pass the entity collection to the control? Because if you do that via a property or method call, you have to pass in an entitycollection implementing object, so a typed list/datatable is not going to work, OR you have to refactor the interface, which would solve the problem also.

(I'm not sure why teh datatable doesn't implement IEnumerable, a dataview does btw.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 04-Feb-2005 18:15:52   

Is DataSource of type object ? Or of type IList?

If it's of type object, you can ofcourse inside the control determine what to do. The thing is: you can use a dataview, created by typedList.DefaultView as an IList simple_smile as it implements IList

Frans Bouma | Lead developer LLBLGen Pro