0
yrojas created
Hi,
I have a scheduled background job to perform a long-running task, it basically works by reading all the records in a table and by each record writing a new record in another table, when are few records it works as expected but when are more than 10000 records throws this exception: "The underlying provider failed on Open."
This is part of my code:
public class MyBackgroundJob : JobBase, ITransientDependency
{
private readonly IRepository<MyEntity, long> _repository;
public MyBackgroundJob(IRepository<MyEntity, long> repository)
{
_repository = repository;
}
public override void Execute(IJobExecutionContext context)
{
using (var unitOfWork = UnitOfWorkManager.Begin())
{
using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant))
{
IQueryable<MyEntity> entities= _repository.GetAll();
foreach (MyEntity entity in entities)
{
.....
Any sugestion? Thanks in advance.
3 Answer(s)
-
0
Hi,
Can you get all records when you change your code to
var entities= _repository.GetAllList();
Thanks.
-
0
Yes, I can.
-
0
Hi,
It might be related to commiting changes of 10.000 records at once. Do you know at which line do you get this error ?