[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem while saving related records to database
- Subject: Problem while saving related records to database
- From: venkatesh at effigent.com (Venkatesh - Internet)
- Date: Mon May 5 21:55:01 2003
This is a multi-part message in MIME format.
------=_NextPart_000_00BE_01C313B9.6E8BA970
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
I encountering a problem while inserting two related entities =
simultaneously in the database.
I have two tables in the database :- Table A and Table B.
>From table A the relationship to table B is to many. Table B cannot =
exists with out table A.
First i am inserting table A in the editing context. Then inserting =
table B in the editing context.
Then i am using the method 'addObjectToBothSidesOfRelationshipWithKey' =
to establish relationship between the above two objects.
When i invoke editingcontext.savechanges(), always object B is being =
attempted to insert first and then object A.
Because of this, referential integrity exception is encountered as =
record in table A does not exist when record in table B is been =
attempted to insert.
Inputs about how to avoid this problem, will be helpful.
Thanks
venkatesh=20
------=_NextPart_000_00BE_01C313B9.6E8BA970
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3315.2870" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>I encountering a problem while =
inserting two=20
related entities simultaneously in the database.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>I have two tables in the database :- =
Table A and=20
Table B.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>From table A the relationship to table =
B is to=20
many. Table B cannot exists with out table A.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>First i am inserting table A in the =
editing=20
context. Then inserting table B in the editing context.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Then i am using the method=20
'addObjectToBothSidesOfRelationshipWithKey' to establish relationship =
between=20
the above two objects.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>When i invoke =
editingcontext.savechanges(), always=20
object B is being attempted to insert first and then object =
A.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Because of this, referential integrity =
exception is=20
encountered as record in table A does not exist when record in table B =
is been=20
attempted to insert.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Inputs about how to avoid this problem, =
will be=20
helpful.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>venkatesh =
</FONT></DIV></FONT></DIV></BODY></HTML>
------=_NextPart_000_00BE_01C313B9.6E8BA970--