Support for DevExpress XPO in SfDataGrid

DevExpress has a great ORM, called XPO, which is now available free of charge. It works great with standard controls: see here

However, when I try to use SfDataGrid instead of DataGridView, despite the fact that it recognizes my XPCollection as a valid DataSource (it looks for Lists in the form), I get "Property value is not valid" and "source is not IEnumerable<>" under "Details". XPO's XPCollection definitely implements IEnumerable, what else am I missing?


22 Replies

VS Vijayarasan Sivanandham Syncfusion Team April 13, 2021 02:07 PM UTC

Hi Adrian Dumitru,

Thank you for contacting Syncfusion Support.

Currently, we are analyzing your requirement of “Support for DevExpress XPO in SfDataGrid” We will validate and update you the details on or before April 15, 2021. 
  
We appreciate your patience until then. 
 
Regards, 
Vijayarasan S 



VS Vijayarasan Sivanandham Syncfusion Team April 15, 2021 11:03 AM UTC

Hi Adrian Dumitru,

Thank you for your patience.

Based on provided information we have tried to achieve the XPCollection in SfDataGrid. But ObjectClassInfo property not enabled for created a simple sample from our end. Please refer the below screen shot for your reference,




If possible, provide a simple sample based on your scenario. We will check the possibilities to achieve your requirement using any workarounds and update you with further details.

Regards,
Vijayarasan S 



AD Adrian Dumitru April 15, 2021 01:03 PM UTC

Thank you for looking into it. Basically, you need to connect to a database first (MS Access with a table or two would work), and create a model from the existing tables, like here: https://docs.devexpress.com/XPO/3334/create-a-data-model/generating-persistent-objects-for-existing-data-tables
Alternatively, can you please provide an email where I can send the sample? I would rather not attach it here, publicly.


AD Adrian Dumitru April 16, 2021 06:18 PM UTC

Alternatively, do you offer/recommend a way to connect to databases, like the one in Bold Report Designer?


VS Vijayarasan Sivanandham Syncfusion Team April 16, 2021 07:24 PM UTC

Hi Adrian Dumitru,

Thanks for the update.

Based on provided information we have checked the your reported scenario “create a model from the existing tables”. But ObjectClassInfo property not enabled for created a simple sample from our end.

In your previous update mentioned the “offer/recommend a way to connect to database”. We have mentioned the database binding for SfDataGrid in user guide documentation. For more information, please refer the below UG link,

UG Link: https://help.syncfusion.com/windowsforms/datagrid/databinding
 
Please let us know, if you require further assistance on this. 
Regards,
Vijayarasan S
 




AD Adrian Dumitru April 16, 2021 07:31 PM UTC

Can you please provide an email so that I can send you a sample?


VS Vijayarasan Sivanandham Syncfusion Team April 19, 2021 04:20 PM UTC

Hi Adrian Dumitru,

Thanks for the update.

You can create the incident under your direct trac account for SfDataGrid control and share the sample in that incident.

We will check the possibilities to achieve your requirement using any workarounds and update with further details.

Regards,
Vijayarasan S
 



AD Adrian Dumitru April 19, 2021 07:30 PM UTC

I don't have a direct trac account.


VS Vijayarasan Sivanandham Syncfusion Team April 21, 2021 03:42 AM UTC

Hi Adrian Dumitru,

Thanks for the update.
 
We have created a new incident under your Direct trac account. We suggest you follow up with the incident for further updates. Please log in using the below link.  

 
Regards, 
Vijayarasan S 



AD Adrian Dumitru April 23, 2021 06:00 AM UTC

You need to build the solution to enable ObjectClasInfo.


CF Charles Fontana April 26, 2021 11:14 AM UTC

I have run across the same problem. See below.



Assigning XpCollection to the SfDatagrid datasource at design time or run time results in the same error.

To enable ObjectClassInfo you must install the trial version of the Winforms controls from Devexpress.

Thanks!


AD Adrian Dumitru April 26, 2021 12:37 PM UTC

I am glad you are now able to reproduce the problem. Do you have a solution, since you are in possession of the SfDataGrid source code, and the error message looks like it is produced by it? Again, I can confirm XPCollection is indeed IEnumerable, here is its definition (just use Visual Studio's "Go to Definition"):
public class XPCollection : XPBaseCollection, IList[T], ICollection[T], IEnumerable[T], IEnumerable {}
I am not sure about the ObjectClassInfo "requirement" to load the demo version of the WinForms controls, since DevExpress would not advertise XPO as free if one could not use it with standard controls. Regardless, I hope you are able to proceed in finding a solution.


VS Vijayarasan Sivanandham Syncfusion Team April 26, 2021 04:19 PM UTC

Hi Adrian Dumitru / Charles Fontana,

Thank you for contacting Syncfusion support.

We could be able to reproduce your reported issue “Property value is not valid and source is not IEnumerable” from our end. We will validate and update you details on or
before April 28, 2021.  
We appreciate your patience until then.

Regards,
Vijayarasan S
 



VS Vijayarasan Sivanandham Syncfusion Team April 28, 2021 06:28 PM UTC

Hi Adrian Dumitru / Charles Fontana,

Thank you for your patience,

Based on provided information we have checked the XPCollection and that collection is not an IEnumerable collection and it makes the exception. You can resolve the reported problem by typecast the collection and set collection into the DataSource property of SfDataGrid. Please refer to the below code snippet, 
SfDataGrid.DataSource = XPCollection.Cast<object>(); 
Stack Overflow Link: https://stackoverflow.com/questions/19535087/source-is-not-ienumerable-error-when-using-sqlquerytype-string-object-as

Please let us know, if you require further assistance on this. 
Regards,
Vijayarasan S 



CF Charles Fontana May 1, 2021 01:45 PM UTC

Casting the XpCollection to IEnumerable works if you are not doing any editing in the sfdatagrid. You have to use an ObservableCollection if you want to do editing in the grid. XpObjects work well with IBindngList because they implement INotifyProperyChange. Since sfDataGrid is a winforms control it is surprising that it does not support IBindngList. IBindingList was created for winforms and ObservableCollection was created for WPF.

Thanks!



AD Adrian Dumitru May 1, 2021 02:35 PM UTC

My remaining issue is that the cast only works at run time, so none of the niceties of the form designer can take advantage of it. I have to do all operations (such as editing columns, master-detail relationships, etc.) in code, manually, instead of through the form designer. It's a sad state of affairs in 2021, especially since Embarcadero (formerly Borland) tools have done it 20 years ago!


VS Vijayarasan Sivanandham Syncfusion Team May 3, 2021 05:04 PM UTC

Hi Charles Fontana/ Adrian Dumitru,

Thank you for contacting Syncfusion Support.

Currently, we are analyzing your requirement of “XPCollection set design time in SfDataGrid” We will validate and update you the details on or before May 05, 2021.

We appreciate your patience until then.

Regards,
Vijayarasan S



VS Vijayarasan Sivanandham Syncfusion Team May 5, 2021 04:35 PM UTC

Hi Charles Fontana/ Adrian Dumitru,

Thank you for your patience.   

We are still working on this. We will update with further details on or before
May 07, 2021. We appreciate your patience and understanding.

Regards,
Vijayarasan S
 



VS Vijayarasan Sivanandham Syncfusion Team May 9, 2021 04:12 PM UTC

Hi Charles Fontana/ Adrian Dumitru,  

Thank you for your patience.     

We are still working on this. We will update with further details on or before May 11, 2021. We appreciate your patience and understanding. 

Regards, 
Vijayarasan S 



VS Vijayarasan Sivanandham Syncfusion Team May 10, 2021 04:31 PM UTC

Hi Charles Fontana/ Adrian Dumitru,

Thank you for your patience.

Your requirement can be achieved by create the custom control for SfDataGrid. You can create the particular property like DataSource and customized the type cast this property and set to DataSource. Please refer the below code snippet, 
public class SfDataGridExt : SfDataGrid 
    { 
        private object itemSource; 
 
        [Category("Data")] 
        [Description("Specifies a collection that is used to generate the content of the SfDataGrid.")] 
        [AttributeProvider(typeof(IListSource))] 
        [DefaultValue(null)] 
        [RefreshProperties(RefreshProperties.All)] 
        [TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design")] 
        [Cloneable(false)] 
        public object ItemSource 
        { 
            get 
            { 
                return itemSource; 
            } 
 
            set 
            { 
                if (value != itemSource) 
                { 
                    itemSource = value; 
                    this.OnItemSourceChanged(value); 
                } 
 
            } 
        } 
 
        public SfDataGridExt() 
        { 
 
        } 
 
        protected virtual void OnItemSourceChanged(object newValue) 
        { 
             //Type cast to Resolve the reported problem and set to SfDataGrid DataSource property 
            DataSource = (ItemSource as XPCollection).Cast<object>(); 
        } 
    } 

Please let us know if you have any concerns in this.

Regards,
Vijayarasan S 



AD Adrian Dumitru May 11, 2021 01:16 AM UTC

Thank you. I hope this makes it into the official version of the control.


VS Vijayarasan Sivanandham Syncfusion Team May 11, 2021 11:47 AM UTC

Hi Adrian Dumitru,

Thanks for the update.

Your reported problem can be resolve by using customization in SfDataGrid. We also regret to inform you that​​​ currently, Our SfDatagrid source architecture does not provide support to achieve your requirement of “Support for DevExpress XPO in SfDataGrid”.

Regards,
Vijayarasan S


Loader.
Up arrow icon