Hello,
sorry for the poor details on my request.
I'm working with a MySQL database with the LinqConnect version 4.4.727.0
My scenario involves two tables, B_POLIZZE and B_CONTENITORI.
The second one has a foreign key IDPOLIZZA linked with the primary key of the first one, in a ON DELETE CASCADE relationship.
Data from the two tables are bound into two datagrid. At the selection of a row in the B_POLIZZE datagrid the corresponding B_CONTENITORI rows are loaded in the second datagrid.
The error occours sometimes (but quite often) trying to delete one or more rows from the B_POLIZZE datagrid, which leads to the deletetion of the linked B_CONTENITORI rows. What the error exactly reports is the following message:
Error System.NullReferenceException: Riferimento non impostato su un'istanza di oggetto.
в xget__IDPOLIZZA_139(B_CONTENITORI)
в Devart.Data.Linq.Mapping.Accessors.d.Accessor`2.GetValue(T instance)
в Devart.Data.Linq.Mapping.Accessors.MetaAccessor`2.GetBoxedValue(Object instance)
в Devart.Data.Linq.Engine.b4.c.c()
в System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
в System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
в Devart.Data.Linq.Engine.c5.i(IObjectEntry A_0)
в Devart.Data.Linq.Engine.c5.l()
в Devart.Data.Linq.Engine.c5.j()
в Devart.Data.Linq.Engine.c5.a.b()
в Devart.Data.Linq.Engine.b5.a(ConflictMode A_0)
в Devart.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
в Devart.Data.Linq.DataContext.SubmitChanges()
The code snippet is:
Code: Select all
For Each BPolizza As B_POLIZZE In dgPolizzeSbarchi.SelectedItems
If BPolizza.ACCETTATA = "S" Then Continue For 'Salto le polizza accettate in quanto gia flussate
RemoveHandler BPolizza.PropertyChanged, AddressOf BRecordPropertyChanged
LinqModule.ManifestiDataContext.B_POLIZZEs.DeleteOnSubmit(BPolizza)
Next
LinqModule.ManifestiDataContext.SubmitChanges()
I also tried to firstly delete the linked B_CONTENITORI rows before deleting the B_POLIZZA row:
Code: Select all
For Each BPolizza As B_POLIZZE In dgPolizzeSbarchi.SelectedItems
If BPolizza.ACCETTATA = "S" Then Continue For 'Salto le polizza accettate in quanto gia flussate
RemoveHandler BPolizza.PropertyChanged, AddressOf BRecordPropertyChanged
For Each BCont As B_CONTENITORI In BPolizza.B_CONTENITORIs
LinqModule.ManifestiDataContext.B_CONTENITORIs.DeleteOnSubmit(BCont)
Next
LinqModule.ManifestiDataContext.SubmitChanges()
LinqModule.ManifestiDataContext.B_POLIZZEs.DeleteOnSubmit(BPolizza)
Next
LinqModule.ManifestiDataContext.SubmitChanges()
I agree a test project able to reproduce the error but unfortunatelly is not so easy for me to provide it, needed to let you also have a DB schema with some data.
Anyway I could try to prepare it, given time.
Regards
Giacomo