using same transaction for asp.net and workflow

aujasonwl6

New Member
Pardon me if my question looks stupid but I am totally new to Workflow. What I am trying to do is : I have some database hits inside the Workflow Foundation project and some in ASP.NET application. What I am trying to achieve is perform database operations inside Workflow foundation and ASP.NET in the same transaction. Tell me is it possible? I am using linq2sql.Here is my code:\[code\] using(var context = new MyDBContext()) { context.Transaction = context.Connection.BeginTransaction(); //Here I am calling my Workflow function using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); if ((string)e.OutputParameters["OutputMessage"] != "") msg = "Workflow error : " + (string)e.OutputParameters["OutputMessage"]; }; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine("ERROR: " + e.Exception.Message); waitHandle.Set(); }; WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(MyWorkflow), parameters); instance.Start(); waitHandle.WaitOne(); } //DB Operation in ASP.NET context.DbOperation(); context.SubmitChanges(); context.Transaction.Commit(); }\[/code\]
 
Back
Top