Insert Parent and Children
Insert Parent and Children
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.
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
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.
- 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
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.
The assertion fails when I attempted to use LinqConnect 4.4.484 with no references to System.Data.Linq.
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);
Re: Insert Parent and Children
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:
Please also refer to http://www.devart.com/linqconnect/docs/ ... lated.html.
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();
Re: Insert Parent and Children
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
We are working on this issue. We will definitely inform you about the results as soon as possible.
Re: Insert Parent and Children
Did 4.4.577 address this issue?
Re: Insert Parent and Children
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.dnchris wrote:Did 4.4.577 address this issue?
Re: Insert Parent and Children
We are looking forward to your reply with the additional information.
Re: Insert Parent and Children
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.
Currently, there are no plans to make any changes for such scenarios.
Please use the workaround, which is described above.