sql server - ServiceStack Ormlite transaction between services -


I'm having trouble with any complex save operation inside the service stack service to simplify the clarification service Ormlite initiates the transaction and makes another service call through ResolveService within it:

  Use the Public ApplicationModel Post (ApplicationModel Request) {(IDbTransaction tr = Db.OpenTransaction ()) Tax {(Var Case = Settle service & lt; CaseService & gt; ()) {request.Case = cases.Post (request.Case); }} DB Save & lt; Application & gt; (Request.Application, true); } Another service (CaseService) also uses a transaction to its logic:  
  Public CaseModel Post (CaseModel Request) {( IDbTransaction tr = DB. Open Transaction ()) {DB. Insert & LT; Case & gt; (request); Db.SaveAllReferences & LT; CaseModel & gt; (request); }}  

With a high hierarchy of services calling other services, in such a situation, "timeout expired" error is thrown, and so far I can not solve it I am, however, closely monitored by SQL Server for Deadlock.

My question is, is it the right way to use / share orchestra transactions or is there any other mechanism?

Thanks in advance.

Instead of calling services to perform DB operations, you should exclude shared transactions.

Use of a separate or reusable extension methods:

  public static class DbExtensions {Public static zero service model (this IDbConnection DB, CaseModel case) {db.Instert & lt; Case & gt; (Case); Db.SaveAllReferences & LT; CaseModel & gt; (matter); }}  

Then your logistics can be maintained by your services, for example:

  Public application modules Post (application model request) {(Var trance = db. Opentransons ()) {db. Swiss model (request .cas); DB Save & lt; Application & gt; (Request.Application, true); Trans.Commit (); }} Public CaseModel Post (CaseModel Request) {(var trans = Db.OpenTransaction ()) {Db.SaveCaseModel (Request); Trans.Commit (); }}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -