ELIStError on attach method

Discussion of open issues, suggestions and bugs regarding EntityDAC
Post Reply
bargiotto
Posts: 2
Joined: Tue 17 Mar 2020 13:37

ELIStError on attach method

Post by bargiotto » Tue 17 Mar 2020 20:47

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);

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: ELIStError on attach method

Post by ViktorV » Wed 18 Mar 2020 13:29

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).

bargiotto
Posts: 2
Joined: Tue 17 Mar 2020 13:37

Re: ELIStError on attach method

Post by bargiotto » Wed 18 Mar 2020 17:11

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.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: ELIStError on attach method

Post by ViktorV » Thu 19 Mar 2020 10:50

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).

ketas
Posts: 28
Joined: Thu 02 Sep 2010 12:08

Re: ELIStError on attach method

Post by ketas » Wed 01 Apr 2020 10:48

Hi,

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

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: ELIStError on attach method

Post by MaximG » Fri 03 Apr 2020 10:39

So far we haven't received the source code of a sample application where the issue could be reproduced and investigated.

Post Reply