entity .ToList() generates a System.OutOfMemoryException

后端 未结 3 2010
忘了有多久
忘了有多久 2021-01-21 10:03

I have a table with half a million rows. I need to update every single row but the ToList() fails:

List allContacts = objDatabase.Contacts.ToList         


        
3条回答
  •  鱼传尺愫
    2021-01-21 10:29

    How about

    IEnumerable allContacts = objDatabase.Contacts.AsEnumerable();
    

    Never convert allContacts to a list. Just use is like an enumerator and apply Foreach loop to access each contacts.

提交回复
热议问题