Error deleting an detail entity

In a master detai relationship, is it possible to change a detail object, delete another detail object, include a new detail object, and use a single put (master) command to process all inclusions, changes, and deletions?

I can change a master object, change a detail object, include a new detail object, without problems, but deleting a detail object returns the following error:

'XData server request error.
Uri: http: // localhost: 2001 / tms / xdata / Invoice (1)
Status code: 500
Error Code: InvalidPointer
Invalid pointer operation '.

I noticed that the server tries to perform an update on the database for the deleted record, is this behavior correct? Would not I have to delete?
Hello Miari, yes, it's possible. You didn't provide detailed information of your process (how are you exactly changing the master object, detail object and sending back to the server). 
But I could suggest two things:

1. Recompile your server using
XDataModule.PutMode := TXDataPutMode.Merge;
Send a header 
xdata-put-mode: merge
in your HTTP Request

2. Add TCascadeType.RemoveOrphan to the [ManyValuedAssociation] mapping of your detail objects. This will tell Aurelius that it should delete the detail object if it was removed from the list. Otherwise yes, an update will be performed because the detail object will not be removed (deleted) from the database, but simply be removed from the master (the foreign key will be set to null, but the detail object will still exist).



Merging is the default behavior, ok?

I solved the problem by adding "CascadeTypeAllRemoveOrphan" to the map [manyValuedAssociation] of the detail object.

I was using "CascadeTypeAllButRemove" ...

The mapping of the entity looks like this:

  [Id('FId', TIdGenerator.IdentityOrSequence)]
  TCultura = class
    [Column('ID', [TColumnProp.Required])]
    FId: Integer;

    [Column('NOME', [TColumnProp.Required], 40)]
    FNome: string;

    [ManyValuedAssociation([], CascadeTypeAllRemoveOrphan)]
    [ForeignJoinColumn('ID_CULTURA', [TColumnProp.Required])]
    FVariedadeList: Proxy<TList<TVariedade>>;
    function GetVariedadeList: TList<TVariedade>;
    constructor Create;
    destructor Destroy; override;
    property Id: Integer read FId write FId;
    property Nome: string read FNome write FNome;
    property VariedadeList: TList<TVariedade> read GetVariedadeList;

One more question, Wagner ...

I can not generate the mapping above by TMS DataModeler. I tried in many ways and I could not.

I did not find the option to put "CascadeTypeAllRemoveOrphan" in the Many-Valued Associations tab.

The mapping looks like this:

     [ManyValuedAssociation ([TAssociationProp.Required], [TCascadeType.SaveUpdate,      TCascadeType.Merge], 'FCulture')]
     FVarietyList: TList <TVariety>;

You can use scripting to customize the output:

For changing it to CascadeTypeRemoveOrphan, you can use this specific code:

procedure OnManyValuedAssociationGenerated(Args: TManyValuedAssociationGeneratedArgs);
  case Args.CodeType.Name of
       case Args.Field.Name of  
             TCodeSnippetExpression(Args.AssociationAttr.Arguments[1].Value).Value := 'CascadeTypeRemoveOrphan';