3rd party control only accepts datatable or dataset

Posts   
 
    
MatthewM
User
Posts: 78
Joined: 26-Jul-2006
# Posted on: 04-Aug-2006 23:21:30   

3rd party controls only accept "datatable or dataset" as a datasource. What is the best way to get an EntityCollection to either?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 05-Aug-2006 01:59:29   
Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 06-Aug-2006 18:24:35   

Hi,

The new Projector classes introduced in the latest version can do the job.

You may have a look at the section "Generated code - Fetching DataReaders and projections, Adapter" from the manual, DataProjectorToDataTable should be the projector you want to use.

But now this is if you really want to work with collections in the first place. You may also consider switching to TypedLists, either from within the designer, or completely dynamically in your code, since TypedLists are what produces custom datatable fetchs.

MatthewM
User
Posts: 78
Joined: 26-Jul-2006
# Posted on: 07-Aug-2006 17:13:19   

I have further discovered that they will accept a source that implements either IListSource or IEnumerable. What is strange is that the control won't accept an entitycollection, which of course implements IEnumerable. Strange. Anybody have thoughts? The control set is Teleriks RadControls.

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 07-Aug-2006 17:38:40   

Well there are loads of property, and various event plumbing in the entities. Frans had to specify quite a few attributes before you could properly bind an entitycollection to a simple datagrid.

It does not surprise me that much, supposing that Rad controls have a complex behaviour (don't know them though), that the controls get lost in the many properties you have in an entity. I reckon IEnumerable is about the capability of a collection to nicely split up into entities. But then entities are not trivial objects to deal with.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 08-Aug-2006 11:22:18   

Entitycollections in v2 also implement IListSource and in v1, they also implemented IEnumerable.

They also implement ITypedList, which is the standard interface for this.

Frans Bouma | Lead developer LLBLGen Pro
MatthewM
User
Posts: 78
Joined: 26-Jul-2006
# Posted on: 08-Aug-2006 17:08:34   

Their controls are not recognizing IEnumerable. I am working with them too to resolve this, however at present they are stumped and are suggesting converting to a DataTable or throwing each object in an ArrayList. I have to believe the underlying problem is simple, the question is, does it lie within their code or something within an EntityCollection. Given that EntityCollections clearly implement IEnumerable, I would have to say theirs, yet other (simpler) datasources that implement IEnumerable do bind to their controls.

Any thoughts on how to find out where the problem is?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 08-Aug-2006 18:00:04   

MatthewM wrote:

Their controls are not recognizing IEnumerable. I am working with them too to resolve this, however at present they are stumped and are suggesting converting to a DataTable or throwing each object in an ArrayList. I have to believe the underlying problem is simple, the question is, does it lie within their code or something within an EntityCollection. Given that EntityCollections clearly implement IEnumerable, I would have to say theirs, yet other (simpler) datasources that implement IEnumerable do bind to their controls.

Any thoughts on how to find out where the problem is?

If they can't handle binding an entitycollection, and they have no clue how that can happen, I'd seriously consider buying another control set.

I also fail to see why it fails with an entitycollection but it would succeed with an arraylist.

Could you also explain a bit more what version of llblgen pro we're talking about, what version of .net etc. For llblgen pro v2.0, telerik has made several fixes to their grids so they now behave as they should be.

Frans Bouma | Lead developer LLBLGen Pro
MatthewM
User
Posts: 78
Joined: 26-Jul-2006
# Posted on: 08-Aug-2006 20:54:47   

LLBL v2.0, .Net 2.0, Telerik latest, including unreleased hotfixes. At the moment, I am fussing with their tree control. Yes, I do not understand why it binds to other things that implement IEnumerable, but does not recognize an EntityCollection.

jtgooding
User
Posts: 126
Joined: 26-Apr-2004
# Posted on: 08-Aug-2006 21:42:20   

Not sure I know of any tree control that implements IEnumerable, the issue is IEnumerable does not implement another interface (escapes me at the moment) which defines the relationships between parents and children objects.

This really isn't a Telerik issue IMO.

I had a long talk with the DevExpress guys about Tree controls and data binding, if I can find the resulting email I will post it, but I'm sure its for the same reasons, IENumerable doesn't provide enough information to build an actual tree.

If all you need is a list then a grid which supports nested list collections is a better solution.

Found one of them here it is, the reason DataSet works is you can define relationship objects between two tables in the dataset to create selfreferencing data.

The XtraTreeList is designed for displaying self-referenced data, where parents and children are represented with the same column set and the levels depth may vary from node to node. The XtraTreeList is not suitable for master-detail data. Please use the XtraGrid for such tasks

They do support IList. IBindingList etc. but each of these has some fairly large restrictions on usage where DataView on a dataset does not.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 08-Aug-2006 21:47:17   

MatthewM wrote:

LLBL v2.0, .Net 2.0, Telerik latest, including unreleased hotfixes. At the moment, I am fussing with their tree control. Yes, I do not understand why it binds to other things that implement IEnumerable, but does not recognize an EntityCollection.

As you're using v2.0, an entity collection implements IListSource, which returns an EntityView, which implements ITypedList, IList, IEnumerable among other things. It indeed is their issue...

Frans Bouma | Lead developer LLBLGen Pro
MatthewM
User
Posts: 78
Joined: 26-Jul-2006
# Posted on: 08-Aug-2006 22:51:54   

jtgooding wrote:

Not sure I know of any tree control that implements IEnumerable, the issue is IEnumerable does not implement another interface (escapes me at the moment) which defines the relationships between parents and children objects.

This really isn't a Telerik issue IMO.

I disagree. The reason being: I can bind their tree to a DataTable that contains the heirarchical relationship via a parent Id field. Since a DataTable implements IListSource which of course is just a collection of records, the same logic holds for an EntityCollection.

Ex, I can provide the Telerik tree a DataTable that references itself via a ParentId field and produce trees of N depth.

            tree.DataFieldID = "CategoryId";
            tree.DataFieldParentID = "ParentCategoryId";
            tree.DataTextField = "Name";
            tree.DataValueField = "CategoryId";

Admittedly, they did a good job, making it very easy to bind like related data, such as a virtual folder structure. By their own admission, anything that implements IEnumerable is a valid datasource:

r.a.d.treeview can be bound to datasources that implement the IListSource interface (DataSet / DataTable) and / or IEnumerable. You can implement IListSource in your custom datasource...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 09-Aug-2006 00:15:57   

MatthewM wrote:

jtgooding wrote:

Not sure I know of any tree control that implements IEnumerable, the issue is IEnumerable does not implement another interface (escapes me at the moment) which defines the relationships between parents and children objects.

This really isn't a Telerik issue IMO.

I disagree. The reason being: I can bind their tree to a DataTable that contains the heirarchical relationship via a parent Id field. Since a DataTable implements IListSource which of course is just a collection of records, the same logic holds for an EntityCollection.

Which also implements IListSource wink simple_smile

IListSource doesn't do a lot, it just returns the real data container. What telerik likely does is check if the type of the bound object is a dataset. If not, it won't go further. It wouldn't be the first control vendor who pulls that cheap trick.

However as this is a hierarchical control, it might be they implemented the hierarchies hardcoded with datarelations.

Ex, I can provide the Telerik tree a DataTable that references itself via a ParentId field and produce trees of N depth.

            tree.DataFieldID = "CategoryId";
            tree.DataFieldParentID = "ParentCategoryId";
            tree.DataTextField = "Name";
            tree.DataValueField = "CategoryId";

Admittedly, they did a good job, making it very easy to bind like related data, such as a virtual folder structure. By their own admission, anything that implements IEnumerable is a valid datasource:

r.a.d.treeview can be bound to datasources that implement the IListSource interface (DataSet / DataTable) and / or IEnumerable. You can implement IListSource in your custom datasource...

If that's true, you should be able to bind an entity collection, as it implements IListSource. However because this is asp.net 2.0, it might be they need a hierarchical datasource, which isn't supported by the llblgen pro datasource controls. If they can work with a normal datasource control, they should be able to reproduce it, as an entity collection simply implements IListSource and should work. But again, IListSource is really simple. It depends on what they're doing with the IList returned by IListSource wink

Frans Bouma | Lead developer LLBLGen Pro
MatthewM
User
Posts: 78
Joined: 26-Jul-2006
# Posted on: 09-Aug-2006 17:38:02   

Just to close this out, it appears that in FACT their tree control only supports the following:

DataTable DataSet SiteMapDataSource XmlDataSource IHierarchicalInterface (sp)

And not: IListSource IEnumerable

The DataTable/DataSet implementation is achieved via the control's parentIdfield property. Sadly IMO they could have easily extended that via reflection and used IListSource. Ah well.