Hi,
I am getting following error when I use [UnitOfWork(IsDisabled=true)] on application service method and try to access navigation properties on an entity.
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
If I remove that UOW attribute it works just fine.
What can be the issue?
Thanks
3 Answer(s)
-
0
Hi,
If you disable UoW on an application service, you cannot reach navigation properties if you didn't retrieve them from db in your repository, this is the expected behaviour.
When you remove the UoW attribute, app service automatically become unit of work because in ABP all app services are UoW by default.
Why do you need to disable unit of work ? Maybe we can find another solution.
Thanks.
-
0
Thanks for the reply!
I needed that because I did not want to start transaction. I got that working by setting "isTransactional: false" in UOW attribute.
One more question is should we set isTransactional: false on application service methods which only performs get/select operation? Just to avoid unnecessary starting transactions in such case. Will it be useful to improve the performance?
Thanks!
-
0
Hi,
Yes, if you have an method/service which requires a high performance you can use it.