Dirty entities not saving when saved directly or recursively

Posts   
 
    
ddp74
User
Posts: 15
Joined: 04-Jan-2024
# Posted on: 21-Aug-2025 14:19:45   

Details

  • LLBLGen 5.11.4

  • ASP.Net 4.7.2

  • Adapter

Summary

I've got a really odd issue I can't work out. Regardless of how we save some entities, LLBLGen is not saving them to the database, even though the entity is flagged as dirty. It doesn't matter whether the save is done using recursive true from the parent, or when using adapter.SaveEntity on the dirty entity itself.

I've enabled DQE tracing and there's no UPDATEs output for the dirty entities.

Entity Relations:

  • Entity (CustomListEntity)

    • Entity.CustomListOptions (CustomListOptionEntity)

      • CustomListOptionEntity.CustomListOptionMappingValues (CustomListOptionMappingValueEntity)
    • Entity.CustomListMappings (CustomListMappingEntity)

      • CustomListMappingEntity.CustomListOptionMappingValues (CustomListOptionMappingValueEntity)

aka

CustomList has many CustomListOption

CustomListOption has many CustomListOptionMappingValue

CustomList has many CustomListMapping

CustomListMapping has many CustomListOptionMappingValue

When building I add the CustomListOptionMappingValueEntity entities to the CustomListMapping entities, leaving the collection under CustomlistOptionEntity empty. Creations and deletions work as intended for all entities. Updates work for CustomListEntity.CustomListOptions and CustomListMappingEntity.CustomListOptionMappingValues. Updates for CustomListEntity.CustomListMappings do not go through. IsDirty is true before and after the call to SaveEntity(), and SaveEntity() is returning true to suggest the save was successful. However, the update query is never ran. Note that the child entities CustomListMappingEntity.CustomListOptionMappingValues save updates perfectly fine.

I have tried both saving via a recursive save on the top-level entity, and by manually going through the structure and calling SaveEntity() on each individual entity. In both cases the behaviour is seen.

private void SaveEntity(DataAccessAdapter adapter, CustomListEntity entity)
{
    adapter.SaveEntity(entity, true);

    foreach (CustomListOptionEntity optionEntity in entity.CustomListOptions)
    {
        adapter.SaveEntity(optionEntity, true);
    }

    foreach (CustomListMappingEntity mappingEntity in entity.CustomListMappings)
    {
        adapter.SaveEntity(mappingEntity, true); // Dirty entities are not saved

        foreach (CustomListOptionMappingValueEntity valueEntity in mappingEntity.CustomListOptionMappingValues)
        {
            adapter.SaveEntity(valueEntity, true);
        }
    }
}

For example, the CustomListMappingEntity has a field called MappingKey. If I change the MappingKey from "MaxPortions" to "MaxPortions123", and then call SaveEntity() directly on the mapping entity, then the SaveEntity() call returns a value of "true", but the save never happens. The IsDirty flag on the entity is true both before and after the call, with no query ran against the db.

The data is fetched using a PrefetchPath in case that's of any relevance:

public static IPrefetchPath2 GetCustomListPrefetchPath()
{
    IPrefetchPath2 root = new PrefetchPath2(EntityType.CustomListEntity);
    root.Add(CustomListEntity.PrefetchPathCustomListOptions);
    IPrefetchPathElement2 mappingSets = root.Add(CustomListEntity.PrefetchPathCustomListMappings);

    mappingSets.SubPath.Add(CustomListMappingEntity.PrefetchPathCustomListOptionMappingValues);

    return root;
}
Attachments
Filename File size Added on Approval
image (2).png 24,430 21-Aug-2025 14:20.02 Pending
NoChanges.png 353,499 21-Aug-2025 14:20.51 Pending