On 22 Apr., 14:39, mabu <[email protected]> wrote: > On 22 Apr., 14:17, mabu <[email protected]> wrote: > > > > > > > On 22 Apr., 12:56, mabu <[email protected]> wrote: > > > > Some Code may help: > > > > Data.IMDataContext context = monitor.Context; > > > Data.Report report = new Data.Report() { SuiteID = 1, > > > Rundate = DateTime.Now }; > > > context.Reports.InsertOnSubmit(report); > > > Data.Product p = new Data.Product() { Report = report, > > > Name = "1" }; > > > context.Products.InsertOnSubmit(p); > > > Data.Component c = new Data.Component() { Product = p, > > > Name = "1-1" }; > > > context.Components.InsertOnSubmit(c); > > > Data.Component c2 = new Data.Component() { Product = > > > p, Name = "1-2" }; > > > context.Components.InsertOnSubmit(c2); > > > context.SubmitChanges(); > > > Console.WriteLine("report.ID=" + report.ID); > > > Console.WriteLine("p.ID=" + p.ID); > > > Console.WriteLine("c.ID=" + c.ID); > > > Console.WriteLine("c2.ID=" + c2.ID); > > > DataContext.CurrentTransactionEntities contains 4 entity tracks in > > the first step when GetReferencedObjects(entityTrack.Entity) is > > called. > > > In the first loop run are already inserted 3 items ( objects report, > > p, c ) based on reports object ... they are inserted in the correct > > order and the ID in the objects is updated. > > when i have look at the objects of the CurrentTransactionEntities at > this time the > inserted items are correct updated ( ID and Parent-IDs ), > but second Component ( object c2 ) has not set the correct parent > id... > > altough the Parent objects points to the product which got inserted > and has a correct ID set. > > Seems object tracking has some bug anywhere?
So i made a quick-hack: i update the EntityState if a referenced object is inserted ... now the correct number of records appear in the database and all of them are correct inserted ( Id, parent id, ... ) But there has to be a better solution for this? -- You received this message because you are subscribed to the Google Groups "DbLinq" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/dblinq?hl=en.
