Add several records

Add several records

Postby markdelphi » Tue 13 Sep 2016 00:21

Hello

I'm new using EntityDAC not know how I can have you add multiple entities?
And if I have a master-detail relationship How do I add an entity with its details?

Thank you
markdelphi
 
Posts: 16
Joined: Sat 08 Sep 2012 19:43

Re: Add several records

Postby AlexP » Wed 14 Sep 2016 10:27

Hello,

You can find samples of work with master-detail in the folder \Devart\EntityDAC\Demos\EntityDemo\.
AlexP
Devart Team
 
Posts: 5525
Joined: Tue 10 Aug 2010 11:35

Re: Add several records

Postby markdelphi » Wed 14 Sep 2016 14:48

What occupied this was, I do not know if it's okay

Code: Select all
    Inv := TInventario.Create;
    Inv.NombreFisico := txtGuadarComo.Text;
    Inv.NombreLogico := txtNombreInv.Text;
    Inv.Fecha := dtpckFecha.DateTime;
    Inv.UltimoCodigo := txtUltimoCodigo.Text;
    Inv.UltimoTicket := StrToInt(txtTicket.Text);
    Inv.Attach(Context);
    Inv.Save;
    for i := 0 to chklstDepartamentos.Items.Count -1 do
     begin
      if chklstDepartamentos.Items.Items[i].Checked then
       begin
        InvDepto := TInvDepto.Create;
        InvDepto.IdInventario := Inv.IdInventario;
        InvDepto.Depto := chklstDepartamentos.Items.Items[i].Text;
        InvDepto.Attach(Context);
        InvDepto.Save;
       end;
     end;


I make mistake because in the model the primary key of the detail table is a numerical missing car and set Auto-Sync properties IdGenerator OnInsert and Identity.
markdelphi
 
Posts: 16
Joined: Sat 08 Sep 2012 19:43

Re: Add several records

Postby AlexP » Thu 15 Sep 2016 07:27

Please describe the needed behavior in more detail.
AlexP
Devart Team
 
Posts: 5525
Joined: Tue 10 Aug 2010 11:35


Return to EntityDAC