-1
I have a web application and am using repository* and Unit Of Work.
In some examples I saw that after performing some change operation in the bank we should call the method Dispose()
.
I instancei the UnitOfWork
:
private UnitOfWork unitOfWork = new UnitOfWork();
When making an amendment to update and call the Dispose()
, it is not possible to do the bind in the grid, Yeah, the object went through Dispose()
.
Alternatively, I’m using the using
:
using (UnitOfWork unitOfWork = new UnitOfWork())
{
//Código.
}
My question is: using the Pattern Unit Of Work it is correct to use the using
? If not, where should I call the Dispose()
?
, my inquiry is exactly where to do Dispose(). Since in Web Application I’m not using controllers. The use of using() is only to release resource, however, for this I have to do several instances of Unit Of Work and the idea is not to have to instigate the class several times.
– Alan César
We have no way of knowing for sure, you just posted a snippet. But for the web there is a chance that you even need the
using
. If you run for a very short time, do one or more specific tasks and quit, which is very common on the web, it is not necessary. Ephemeral applications do not need so much care.– Maniero
I understand. Radgrid of Telerik to do the CRUD, directly on the grid. So, basically, I have a Needdatasource, to load the data and use the Command for Insert, Update and Delete.
– Alan César
Who gave the negative could say what is wrong for me to correct. I am sure that there is nothing wrong, but the person can help everyone.
– Maniero