Sorry for the delay.
Walaa wrote:
Since it's normal to only use it to retrieve one object.
I don't understand why you use this code:
infos1.AltitudeSaisie = 345
infos1.Save(True)
infos2.AltitudeSaisie = 222
infos2.Save(True)
Why don't you only use one instance of infos?
I posted the previous sample example in order to show the unexpected behavior of the GetSingleXXX method.
If you want one instance then simply the following code would work:
Dim dossier As New DossierEntity()
dossier.TypeDossier = "MIT-456"
dossier.Save(True)
Dim infos1 As DetailInformationEntity = dossier.DetailInformation
infos1.AltitudeSaisie = 345
infos1.Save(True)
infos1.AltitudeSaisie = 222
infos1.Save(True)
Agree.
But, for example, I have a form with, in the first half, a grid contains a list of DossierEntity and, in the second half some textbox and other databinded components on the DetailInformationEntity of the grid's selected DossierEntity. The wanted behavior is : save the collection only when I quit this form (not when I change the selected "Dossier").
Well! Please read this small scenario:
1) select a DossierEntity named 'Dossier1'. I never enter any information previously for this DossierEntity's DetailInformationEntity (no row in database).
2) put some information in DetailInformationEntity.
3) select an other DossierEntity in the grid
4) select the 'Dossier1' (same as in step 1). You have lost the DetailInformationEntity. There is a new Entity instead.
Of course I can save recursively the Selected DossierEntity on selection change or else when I create a DossierEntity I can create a DetailInformationEntity and save it. But I don't want to change the save information behavior and I can't either in each portion of code which concern entity creation add a hack for solve this strange behavior.