Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1104
UltraGrid child band not showing columns when using EF classes generated by dotnet command
posted

Hi,

I am using EF class objects as grid datasources generated by command "dotnet ef dbcontext scaffold ...", which reside in another .Net Core project of the VS solution.

The parent class looks like:

namespace myDB.Models
{
    public partial class Parent
    {
        public Parent()
        {
            ParentChild = new HashSet<ParentChild>();
        }

        public int Id { get; set; }
        //some other properties...

        public virtual ICollection<ParentChild > ParentChild  { get; set; }
    }
}

This basically works fine when I only use a simple table with SingleBand.

Now I would like to also show the parent's children in the grid.

The child class:

namespace myDB.Models
{
    public partial class ParentChild
    {
        public int Id { get; set; }
        public int ParentId { get; set; }
        public string Name { get; set; }
        //some other properties...

        public virtual Parent Parent { get; set; }
    }
}

But in the grid it does not show me the children columns, instead I see 2 columns "IsReadOnly" and "Count". It seems like it has a problem with the HashSet or the ICollection property (which are generated by the .Net Core command by default).

Is there a way to solve this without having to edit the generated classes too much?

Thank you,

best regards

Parents
No Data
Reply
  • 34430
    Offline posted

    Hello Daniel,

    I have been investigating into the issue that you are reporting, and I have put together a sample class structure that is consistent with the one you have provided, but in doing so, I cannot seem to reproduce the behavior you are seeing. The UltraGrid is handling the hierarchy normally on my end. Perhaps there is another partial “Parent” or “ParentChild” class in your application somewhere?

    I was speaking with my colleague and he had also recommended using a BindingList<T> instead of using an ICollection<T> or HashSet<T> for your “ParentChild” hierarchy in this case. I am unsure if this will help you here, though, as HashSet<T> is working on my end.

    I have attached the sample project I used to test this.  Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.

    If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using.  My test was performed using version 18.2.20182.175 in Infragistics for Windows Forms 2018 Volume 2.

    If the project does show the product feature working correctly, this indicates a possible problem in the code of your application.  It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.

    Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.

    Please let me know if you have any other questions or concerns on this matter.

    UltraGridHashSetTest.zip

Children