views:

116

answers:

1

Hi,

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!!

+2  A: 

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