Reputation: 283
I am using EF 5, Model First, on .NET 4.5 with Win Server 2012 and SQL Server Express 2008 R2.
There are basically three main components in my app:
I also implemented a scheduler class to basically have other classes schedule some operations e.g. data acquisition and reporting.
Data acquisition's polling executes at every 5 seconds and writes data to a table in the DB. This works fine, no problem here.
The reporting gets invoked at every 24 hours, at midnight and it retrieves data from database and generates spreadsheet and emails it. At midnight, when the event fires, in the event handler's using block for DbContext
, there are no data retrieved from database. However, if I manually call the event handler from other method, the very same using block's DbContext has all the data.
I cannot find what the problem is with it when the handler invoked from event. I have tried to use TranscationScope
on the data acquisition write operation to allow RepetitiveRead
but this worsened the problem. I removed the TransactionScope
around the write operation.
Please suggest any ways to narrow down my investigation and solving the problem.
Thanks in advance.
Upvotes: 1
Views: 175
Reputation: 283
Having had found no solution, I've gone ahead and modified my code to internally call the event handler from a while loop instead of from the Schedular class's event trigger.
Upvotes: 1