2

Having trouble getting this. I need get the values that I have added to a table entity through the InsertOnSubmit method. However I have not yet invoked SubmitChanges on the table.

So, I have this in a loop: mdmDC.tblMDMListItems.InsertOnSubmit(listItemsTable);

But I'd like to query mdmDC.tblMDMListItems for some values entered so far, yet I cannot seem to do that. Even after that code above the count on mdmDC.tblMDMListItems is 0.

How can I get the values added before SubmitChanges?

Thanks!!

jason
  • 236,483
  • 35
  • 423
  • 525
user259286
  • 977
  • 3
  • 18
  • 38

1 Answers1

2

Use DataContext.GetChangeSet and the ChangeSet.Inserts property.

// db is DataContext
ChangeSet cs = db.GetChangeSet();
foreach(var item in cs.Inserts) {
    // do something
}

Note that item is not strongly-typed. In fact, it can not be because the DataContext could be tracking items of differing types corresponding to multiple tables.

jason
  • 236,483
  • 35
  • 423
  • 525