InsertOnSubmit(entity)

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
kboeckm
Posts: 10
Joined: Tue 14 Jun 2011 20:47

InsertOnSubmit(entity)

Post by kboeckm » Mon 15 Aug 2011 20:58

I have Entity A that contains child entity B which contains child entity C. Entities A and B have unique keys are are database generated via a sequence generator. Child entity C does not have a unqiue key. Rather it uses a composite key consisting of entity B's unique key and a languagekey (which is not database generated). When I create a new entity of type A that contains two entities of type B each containing any number of entity C and try to execute

datacontext.Items.InsertOnSubmit(A);

I receive an error message (see below). Is there something special I need to do with composite keys?

Visual Studio 2010
LinqConnect 2.50.25.0
dotConnect 6.30.172
Code the errors:
targetDataContext.GetTable(entity.GetEntityType()).InsertOnSubmit(entity);

Error:
Can not insert entity with the same key if key is not database generated.

Stack Trace:
at Devart.Data.Linq.Table.a(Object A_0, Object A_1, MetaType A_2)
at Devart.Data.Linq.Table.a(Object A_0, MetaType A_1, Dictionary`2 A_2, Boolean A_3)
at Devart.Data.Linq.Table.a(Object A_0, MetaType A_1, Dictionary`2 A_2, Boolean A_3)
at Devart.Data.Linq.Table.a(Object A_0, MetaType A_1, Dictionary`2 A_2, Boolean A_3)
at Devart.Data.Linq.Table.a(Object A_0, MetaType A_1, Dictionary`2 A_2, Boolean A_3)
at Devart.Data.Linq.Table.a(Object A_0, MetaType A_1, Boolean A_2)
at Devart.Data.Linq.Table.a(Object A_0, Boolean A_1, Boolean A_2)
at Devart.Data.Linq.Table.c(Object A_0, Boolean A_1)
at Devart.Data.Linq.Table`1.InsertOnSubmit(TEntity entity)
at Devart.Data.Linq.Table`1.d(Object A_0)

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 16 Aug 2011 17:15

I've sent you a test project, please check that the letter was not blocked by your mail filter. Please tell us what should be changed in the sample to reproduce the problem, or send us your test project.

If the problem occurs when running the sample, please try updating to the latest 2.50.30 build of LinqConnect and tell us if this helps (there were several fixes since the 2.50.25 version that may be related to the issue).

Post Reply