i will use MusicLibraryVCL Demo as an example what i am trying to achieve. What i want to do is saving new track to album without saving whole parent object. I changed after post event of adsTracks to:
procedure TAlbumForm.adsTracksAfterPost(DataSet: TDataSet);
Record goes to database but TRACKS_ALBUM_ID is Null. How i can set TRACKS_ALBUM_ID when flushing object without doing FManager.Flush(Album)
TTrack entity doesn't have a field mapping back to
TAlbum. So all association information is in
TAlbum, and that's the only "side" that can be used to setup a relationship between albuns and tracks.
To do what you want, you need first to map a bidirectional association, by adding a
FAlbum: TAlbum field in the
TTrack entity. Then you should modify the
ManyValuedAssociation attribute in album entity to refer to
That process is also explained here: How to Access Parent Entity - #2 by wlandgraf
Note that, when you do that, you must always explicitly set the TTrack.Album property, it will not be set automatically even if you add the track object to the TAlbum.Tracks list.