Certainly
// Fetch the asset and its artists
AssetEntity assetEntity = new AssetEntity((long)1);
IPrefetchPath2 assetPrefetch = new PrefetchPath2(EntityType.AssetEntity);
assetPrefetch.Add(AssetEntity.PrefetchPathAssetToArtistCollection).SubPath.Add(AssetToArtistEntity.PrefetchPathArtist);
assetEntity.DbRead(assetPrefetch, true);
// Get the first artist via the asset to artist collection
var firstAssetToArtist = assetEntity.AssetToArtistCollection.FirstOrDefault();
if (firstAssetToArtist != null)
{
var firstArtist = firstAssetToArtist.Artist;
if (firstArtist != null)
{
// Dirty the artist's name field
firstArtist.Name = firstArtist.Name + "X";
// Output the current state
System.Diagnostics.Debug.WriteLine($"1) assetEntity.IsDirty: {assetEntity.IsDirty}, firstArtist.IsDirty: {firstArtist.IsDirty}");
// Set the Asset's IsDirty to true, this is because we tie the enabled state of the
// save button to the entitie's IsDirty flag. Even though the Asset is not dirty, one
// of its related entities is
assetEntity.IsDirty = true;
// Output the current state
System.Diagnostics.Debug.WriteLine($"2) assetEntity.IsDirty: {assetEntity.IsDirty}, firstArtist.IsDirty: {firstArtist.IsDirty}");
// Create new General Database Adapter
using (BengalDataAccessAdapter adapter = new BengalDataAccessAdapter())
{
// Do a recursive save on the Asset, it will save the Artist with the updated name
adapter.SaveEntity(assetEntity, true, true);
// Output the current state
System.Diagnostics.Debug.WriteLine($"3) assetEntity.IsDirty: {assetEntity.IsDirty}, firstArtist.IsDirty: {firstArtist.IsDirty}");
}
}
}
Output when running with LLBLGen version 5.6.0.0
1) assetEntity.IsDirty: False, firstArtist.IsDirty: True
2) assetEntity.IsDirty: True, firstArtist.IsDirty: True
3) assetEntity.IsDirty: False, firstArtist.IsDirty: False << Note, after save, assetEntity.IsDirty was set to False by the framework
Output when running withLLBLGen version 5.10.0.0
1) assetEntity.IsDirty: False, firstArtist.IsDirty: True
2) assetEntity.IsDirty: True, firstArtist.IsDirty: True
3) assetEntity.IsDirty: True, firstArtist.IsDirty: False << Note, after save, assetEntity.IsDirty is still set to True