If I have a TAureliusDataset
instance using a source list and, after opening the dataset, I do something to change the dataset's layout (e.g. - change field indexes) before calling Insert
, subsequently attempting to read any field's value before calling Post
causes the inserted record to "vanish" and any field values that may have been previously set are seemingly lost. Calling Post
after this results in an access violation exception.
Below is some simple code to demonstrate. Assume that TMyEntity
has two or more properties and one of them is a string
called MyField
.
var ds := TAureliusDataset.Create(nil);
var list := TList<TMyEntity>.Create;
ds.SetSourceList(list);
ds.Open;
ds.Fields[0].Index := (ds.Fields.Count - 1);
ds.Insert;
ds.FieldByName('MyField').AsString := 'A';
var myFieldVal := ds.FieldByName('MyField').AsString; // myFieldVal should end up 'A' but instead is '' (empty string)
ds.Post; // AV occurs here