Add several records

Discussion of open issues, suggestions and bugs regarding EntityDAC
Post Reply
markdelphi
Posts: 17
Joined: Sat 08 Sep 2012 19:43

Add several records

Post by 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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Add several records

Post by AlexP » Wed 14 Sep 2016 10:27

Hello,

You can find samples of work with master-detail in the folder \Devart\EntityDAC\Demos\EntityDemo\.

markdelphi
Posts: 17
Joined: Sat 08 Sep 2012 19:43

Re: Add several records

Post by 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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Add several records

Post by AlexP » Thu 15 Sep 2016 07:27

Please describe the needed behavior in more detail.

Post Reply