Page 1 of 1

Insert Parent and Children

Posted: Tue 13 May 2014 13:58
by dnchris
We're having an issue with LinqConnect after upgrading from 3.2.x to 4.4.484.

When trying to insert a parent and child records on a single SubmitChanges(), we receive FK constraint violations for the child record.

The new children entities are added to the parent's collections. Our team uses a custom entity template to generate code. The LQML has AutoSync="Insert" for any property that IsPrimaryKey and IsDbGenerated.

Re: Insert Parent and Children

Posted: Wed 14 May 2014 12:31
by MariiaI
Please specify the following information:
- the DBMS you are working with;
- the DDL scripts of the necessary database tables;
- the definitions of the DataContext class and entity classes;

If possible, please send us a test project, so that we could investigate the issue in more details and find the solution for you.

JIC: we have made a major refactoring of the LinqConnect engine since version 4.0. Since this version the references to System.Data.Linq are removed, LinqConnect uses only its own classes. So, it is necessary to replace all occurrences of "System.Data.Linq." with "Devart.Data.Linq.". Please check that your code (*.Designer.cs file) doesn't contain "System.Data.Linq." and there is no reference to the System.Data.Linq assembly.

Looking forward to your reply.

Re: Insert Parent and Children

Posted: Tue 01 Jul 2014 22:19
by dnchris
I can't change to the latest version because I'm actively developing in dotConnect for Oracle 6.80.x.

We are using Oracle, but the problem happens at runtime prior to any database connection being established. The best I can do, for now, is provide this pseudo-code:

Where Parent is a POCO with public collection of Child (Children,) and Context is the LinqConnect data context.

Code: Select all

var parent = new Parent();
var child = new Child();

parent.Children.Add(child);

Context.Parents.InsertOnSubmit(parent);

var changeSet = Context.GetChangeSet();
Assert.IsTrue(changeSet.Inserts.Count == 2);
The assertion fails when I attempted to use LinqConnect 4.4.484 with no references to System.Data.Linq.

Re: Insert Parent and Children

Posted: Wed 02 Jul 2014 12:50
by MariiaI
Thank you for the additional information. We have reproduced this issue. We will investigate it and inform you about the results as soon as any are available.
To resolve the issue, please rewrite your code in the following way:

Code: Select all

Parent parent = new Parent();
 Child child = new Child() { Parent = parent };
 Context.Parents.InsertOnSubmit(parent); 
 var changeSet = Context.GetChangeSet();       
 Context.SubmitChanges();
Please also refer to http://www.devart.com/linqconnect/docs/ ... lated.html.

Re: Insert Parent and Children

Posted: Tue 05 Aug 2014 20:21
by dnchris
We can re-write some of our code, but if there has been any movement on this we'd rather download the updated version. Thanks.

Re: Insert Parent and Children

Posted: Wed 06 Aug 2014 05:26
by MariiaI
We are working on this issue. We will definitely inform you about the results as soon as possible.

Re: Insert Parent and Children

Posted: Mon 08 Sep 2014 13:43
by dnchris
Did 4.4.577 address this issue?

Re: Insert Parent and Children

Posted: Mon 08 Sep 2014 14:32
by MariiaI
dnchris wrote:Did 4.4.577 address this issue?
No, this build doesn't include the fix for this issue. We are working on it, but we can't tell any timeframe at the moment. We will definitely inform you about the results as soon as any are available.

Re: Insert Parent and Children

Posted: Fri 03 Oct 2014 20:28
by anamta
We are looking forward to your reply with the additional information.

Re: Insert Parent and Children

Posted: Fri 07 Nov 2014 11:56
by MariiaI
We have investigated this behaviour and it is related to the POCO limitations.
Currently, there are no plans to make any changes for such scenarios.
Please use the workaround, which is described above.