Hi all,
I am running into a problem when selecting a single record from our email database.
The record is over 25MB (estimated, probably more) in size and every time I try to get it from the context it throws an OutOfMemoryException.
NoTracking is unfortunately no option in this case in order to avoid the second copy.
The application copies emails to an archive database and I already set the batch size to 1 record per context before disposing and recreating the context (using statement)
Here is a stub for the function in question:
using (EmailDataEntities context = ContextFactory.GetEmailDataEntities())
{
using (EmailArchiveDataEntities contextArchive = visualbooking.EmailArchiveDataContext.ContextFactory.GetEmailArchiveDataEntities())
{
foreach (long id in idList)
{
try
{
EmailDataContext.Model.tblEMailPostBox oDataEmail = context.tblEMailPostBox.FirstOrDefault(f => f.id == id);
}
catch (Exception ex)
{
}
}
}
}
The exception is thrown in the .FirstOrDefault() part, copying and saving is working in all cases except in the case of the big record.
Right now I just skipped the record. It is possible to copy it manually in the database, but I'd like to know about the background causing the problem... or the limits of records if there are any...
Is there a way to get the record regardless of its size?
Or is there a workaround?
Any help is kindly appreciated,
have a great day
Andy