0

I have a small app that's retrieving about 100 sets of data from the Internet, processing them, then writing them to database using Entity Framework.

The problem is that when processing the data, it needs to check the database and see if previous sets already contain certain data. If I don't call db.SaveChange() after each set, the changes not reflected. Is there a way to access the previous sets without calling db.SaveChange() after every set of data?

foreach (var item in items)
{
    if (db.Where...) // new changes not reflected here unless call db.SaveChange every time
        //do something

    db.SaveChange() // I want to move this out of the loop
}

Thanks!

Rui Jarimba
  • 11,166
  • 11
  • 56
  • 86
Jim
  • 1,695
  • 2
  • 23
  • 42
  • 1
    http://stackoverflow.com/questions/5455972/entityframework-show-entities-before-saving-changes and http://stackoverflow.com/questions/6990618/querying-objects-after-addobject-before-savechanges – StackTrace Apr 11 '13 at 05:48
  • Thanks! Why I didn't think of searching for "save change"... – Jim Apr 11 '13 at 06:43

0 Answers0