Delete new entity without reloading grid
Posted: Mon 26 Mar 2012 17:59
I have a legacy Oracle 10g table which does not have a column defined as a Primary key but it is set to Not Null (named ID).
After I add a new entity to my DbContext, I then retrieve the Sequence generated ID:
then I refresh my datagrid:
which changes the ID in grid from 0 to the proper ID value.
and finally if I try to delete this new entity which has the proper Oracle generated ID, I receive a "the property 'ID' is part of the object's key information and cannot be modified" error.
In my Entity Model ID is, of course, set to Entity Key, Nullable = False, and StoreGeneratedPattern = Identity.
Without rebinding my Bindsource, is there a way to make this work?
After I add a new entity to my DbContext, I then retrieve the Sequence generated ID:
Code: Select all
Public Shared Sub UpdateID(ByRef entity As TBLUDACMAP, context As Entities)
Dim LastDate As Date = entity.LAST_OPERATOR_DATE
Dim NewId As Decimal = (From tbl In context.TBLUDACMAPs
Where tbl.LAST_OPERATOR_DATE = LastDate
Select tbl.ID).Single()
entity.ID = NewId
End Sub
Code: Select all
BindingSource.ResetCurrentItem()
and finally if I try to delete this new entity which has the proper Oracle generated ID, I receive a "the property 'ID' is part of the object's key information and cannot be modified" error.
In my Entity Model ID is, of course, set to Entity Key, Nullable = False, and StoreGeneratedPattern = Identity.
Without rebinding my Bindsource, is there a way to make this work?