Reputation: 309
I am using LINQ to select bulk data(156000 Records) from DB. But am getting the following error.
An exception of type 'System.OutOfMemoryException' occurred in System.Data.Entity.dll but was not handled in user code
Am using select query as follows,
var allCompanies = from s in db.Data.AsNoTracking().ToList()
select s;
Please help me to resolve this issue
Upvotes: 0
Views: 385
Reputation: 277
That is a large amount of records being retrieved. You may need more memory. Have you checked the amount of memory available on your System while this program is executing?
You may want to filter the data or make use of pagination by retrieving certain fixed rows of data at a time.
If it is viable, if you are considering processing the data after retrieving it, you might as well do that in a Stored Procedure.
Upvotes: 2