0
lgarcia created
Hello, I have this code working fine in an ApplicationService but the same code in a Worker is throwing ObjectDisposedException.
var query = _repository.Query(x => x.OfType<MyChildEntity>());
var result = await query.FirstOrDefaultAsync();
Is there something that I'm doing wrong? Thanks in advance.
2 Answer(s)
-
0
You need to be in an UnitOfWork when you call .FirstOrDefaultAsync(). You can first try the [UnitOfWork] attribute on a public virtual function. If that does not work, you need to inject and use IUnitOfWorkManager.
-
0
<cite>aaron: </cite> You need to be in an UnitOfWork when you call .FirstOrDefaultAsync(). You can first try the [UnitOfWork] attribute on a public virtual function. If that does not work, you need to inject and use IUnitOfWorkManager.
Thank you for your quick respone, It worked with the [UnitOfWork] attribute :D.