Hi,
We've got the following code:
using (Session.Current.DisableSaveChanges())
{
MOSPadExport mosPadExport = ImporteerBaseLineEnMaakNieuwProject();
WerkpakketEntity werkPakket = CreeerNieuwWerkpakketMetActiviteit();
UitvoerderEntity uitvoerder = Query.All<UitvoerderEntity>().FirstOrDefault();
Assert.IsNotNull(uitvoerder, "Uitvoerder is null");
OfferteEntity offerte = new OfferteEntity
{
PrognoseOntvangst = DateTime.Now.AddDays(20),
Werkpakket = werkPakket,
Uitvoerder = uitvoerder
};
return werkPakket;
}
In the past we had some problems when creating entities without the 'DisableSaveChanges()' because DO would write entities to the DB before they were properly filled. The DisableSaveChanges() prevents entities being written to the DB before the are intialized correctly.
Today a unit test failed stating that a certain entity was not in the a certain entity set. I debugged it and found a weird problem. In the code below the entity is added to the list but after the Add it is not in the list at all:
public void ItemAdded(object sender, WerkRegelEntity werkRegel)
{
using (new UserId(Projecten.Model.Entities.UserId.EnumUserId.Machine))
{
PadStatusMomentEntity.PadStatusMomentType statusType = GetStatusType(werkRegel);
PadWerkRegelStatusMomentEntity statusMomentAanvraag = new PadWerkRegelStatusMomentEntity
{
WerkRegel = werkRegel,
StatusType = statusType,
Datum = DateTime.Now
};
werkRegel.PadActiviteit.PadStatusMomentList.Add(statusMomentAanvraag);
}
}
Setting a breakpoint directly after the add to the PadStatusMomentList and looking in the list the debugger tells me that the 'enumeration yielded no results'.
Now when I comment the 'using (Session.Current.DisableSaveChanges())' line out in the first code snippet, after the add the item is in the list.
So I am assuming here there is a bug in the DisableSaveChanges() code somewhere.
Regards
Paul
asked
Aug 16 '13 at 03:06
Paul Sinnema
261●88●88●96