How can I find if a DataSet is a master in a master / detail relationship in Delphi?

I want to create a "Duplicate Record" action that, when called, duplicates the current record in any TDataSet stream. How can I find out if a dataset is the main dataset of the relationship between the master and the parts? With TClientDataSet this is pretty easy, but I need this action to be used with all TDataSet descendants.

+6
source share
1 answer

You must call the TDataSet method. GetDetailDataSets . If the list is not empty, then this data set is the main data set for the data sets in the list. For instance:

 var oDetails: TList; lIsMaster: Boolean; ... oDetails := TList.Create; try myDataSet.GetDetailDataSets(oDetails); lIsMaster := oDetails.Count > 0; finally oDetails.Free; end; 
+10
source

Source: https://habr.com/ru/post/923952/


All Articles