Error on procedure TObjectDataSetTest.Open

Issue #211 resolved
Christophe Ravaut created an issue

After adding a new TCustomer into the IList<TCustomer> is the IList<TCustomer>.Count increase. But the recordcount of the dataset is not the same as the IList.Count.

FDataset.DataList.Count <> FDataset.RecordCount

Comments (7)

  1. Christophe Ravaut reporter

    I think the problem is in the TObjectDataSet.DoOnDataListChange. I've add some code and now it pass into the test.

    See changed code (Begin Add Code ... End Add Code)

    procedure TObjectDataSet.DoOnDataListChange(Sender: TObject;
      const Item: TObject; Action: TCollectionChangedAction);
    begin
      if not Active then
        Exit;
    
      if IndexList.IsChanging then
        Exit;
    
    // Begin Add Code
      if (Action = caAdded) and
         (Assigned(Item)) and
         (Assigned(fDataList)) and
         (IndexList.IndexOf(Item)= -1)then
      begin
        IndexList.Rebuild;
      end;
    // End Add Code
    
      DisableControls;
      try
        Refresh;
      finally
        EnableControls;
      end;
    end;
    
  2. Log in to comment