Page 1 of 1

ELIStError on attach method

Posted: Tue 17 Mar 2020 20:47
by bargiotto
When I run this code, I get "Elisterror : The list don't allow duplicates"
When the first object of type TChiamata is attached the primary key remain the same and this create the error when attach the second object (tchiamata)
I know that primarykey is incremented into database layer. Why this happens ? Doesn't attach method increment the key?
Any suggestions?

var
p : TContatto;
c,c1 : TChiamata;
begin
p := tcontatto.Create;

p.Cognome := 'Giorgio';
p.Nome := 'Bartolo';
p.Indirizzo := 'V.le J.F. Kennedy';
p.Numero_Civico := '87';
p.CAP := '70124';
p.Paese := 'Italia';
p.Numero := '3936620642';

c := TChiamata.Create;

c.Data := Now;
c.Ora := Time;
c.Durata := 10.2;
c.NumeroChiamato := '0805610257';

c1 := TChiamata.Create;

c1.Data := Now;
c1.Ora := Time;
c1.Durata := 10.2;
c1.NumeroChiamato := '0805610257';

mdati.EntityContext1.Attach(p);


mdati.EntityContext1.Attach(c);

mdati.EntityContext1.Attach(c1); // here the error is arised

p.Chiamate.Add(c);
p.Chiamate.Add(c1);



MDati.EntityContext1.Save(p);



MDati.EntityContext1.Save(c);
MDati.EntityContext1.Save(c1);

Re: ELIStError on attach method

Posted: Wed 18 Mar 2020 13:29
by ViktorV
To give you a detailed answer, we first need to look into code that exposes such behavior. Please send us using the contact form https://devart.com/company/contactform.html a small code sample demonstrating the behavior, including the scripts for creating database objects, and your model (*.enml).

Re: ELIStError on attach method

Posted: Wed 18 Mar 2020 17:11
by bargiotto
Hi, I only want to know , the right way to create a master entity with a detail collection and save it. And then get it back from the database with detail in one step.If it is possible. Thanks.
For example : new DEPT entity; new EMP1 entity , new EMP2 entity ...and so on, then DEPT.EMPS.ADD(EMP1); DEPT.EMPS.ADD(EMP2)...at last DEPT.save.

Re: ELIStError on attach method

Posted: Thu 19 Mar 2020 10:50
by ViktorV
As we mentioned earlier, to give you a detailed answer, we first need to look into code that exposes such behavior. Please send us using the contact form https://devart.com/company/contactform.html a small code sample demonstrating the behavior, including the scripts for creating database objects, and your model (*.enml).

Re: ELIStError on attach method

Posted: Wed 01 Apr 2020 10:48
by ketas
Hi,

have same error , any news? I am not able to run nothing with entitydac, use it somebody in production?
Vojslav

Re: ELIStError on attach method

Posted: Fri 03 Apr 2020 10:39
by MaximG
So far we haven't received the source code of a sample application where the issue could be reproduced and investigated.