Page 1 of 1
Add several records
Posted: Tue 13 Sep 2016 00:21
by markdelphi
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
Re: Add several records
Posted: Wed 14 Sep 2016 10:27
by AlexP
Hello,
You can find samples of work with master-detail in the folder \Devart\EntityDAC\Demos\EntityDemo\.
Re: Add several records
Posted: Wed 14 Sep 2016 14:48
by markdelphi
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.
Re: Add several records
Posted: Thu 15 Sep 2016 07:27
by AlexP
Please describe the needed behavior in more detail.