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
2265
Entity Framework Multiple Band Issue with Parent/Child relationships
posted

I am binding my UltraGrid to an Entity Framework (nHydrate) data source (System.Windows.Forms.BindingSource).  So for examples sake:

ClassA (Band 0)
    ClassB (Band 1)

I can add rows to Band 0 without any problems using the Fixed Header Row.  I am using the AllowAddNew = FixedAddRowOnTop to do this.  I am doing the same with Band 1.

However, when I add a new row in Band 1, a new instance of ClassB is created which I can see in the AfterRowUpdate event.  However, the relation between ClassA and ClassB is never set and if I try to save the context I get the error:

The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.

If I manually try to set the relationship either by adding CType(e.Row.ParentRow.ListObject, ClassA).ClassB.ToList().Add(<the new ClassB row> ), then I get an extra row in the grid in Band 1.

This is frustrating me as I have spent a lot of late nights trying to work around this.  I cannot see any way to proceed with the grid - I hope I am wrong.

Any thoughts?

Thanks

Andez

 

 

 

 

Parents Reply Children
No Data