I'm having issues with a rather complicated save operation inside a ServiceStack service. To simplify the explanation, the service starts the Ormlite transaction and inside it calls another service through the ResolveService:
public ApplicationModel Post(ApplicationModel request)
{
using (IDbTransaction tr = Db.OpenTransaction())
{
using (var cases = ResolveService<CaseService>())
{
request.Case = cases.Post(request.Case);
}
}
Db.Save<Application>(request.Application, true);
}
Another service (CaseService) also uses a transaction to execute its logic:
public CaseModel Post(CaseModel request)
{
using (IDbTransaction tr = Db.OpenTransaction())
{
Db.Insert<Case>(request);
Db.SaveAllReferences<CaseModel>(request);
}
}
In a similar situation with a higher hierarchy of services that call other services, an error “Timed out” is thrown, and so far I have not been able to solve it, although I have carefully watched SQL Server for deadlocks.
My question is, is this the right way to use / share Ormlite transactions between services, or is there another mechanism?
Thanks in advance.