locked
The transaction operation cannot be performed because there are pending requests working on this transaction? RRS feed

  • Question

  •  Hi, I received this exception when "Context.SaveChanges()" is called in one of my methods in my DomainService class.

    The method which call "Context.SaveChanges()" is called from HTTP Handler which property IsReusable returns "false".

    My code is something like:

     

    1    //HTTP HANDLER
    2 public class MyHttpHandler : IHttpHandler
    3 {
    4 public void ProcessRequest(HttpContext context)
    5 {
    6 ....
    7 MyDomainService.Current.SaveData(data);
    8
    }
    9
    10    public bool IsReusable
    11 {
    12 get { return false; }
    13 }
    14 }
    15
    16 //DOMAIN SERVICE
    17 public class MyDomainService : LinqToEntitiesDomainService<SomeEntities>
    18 {
    19 .....................
    20
    21 private static MyDomainService service = null;
    22
    23 static MyDomainService()
    24 {
    25 service = new MyDomainService();
    26 }
    27 // I've tried to lock the property but it doesn't work!!!
    28 public static MyDomainService Current
    29 {
    30 get
    31 {
    32 lock (service)
    33 {
    34 return service;
    35 }
    36 }
    37 }
    38
    39 public void SaveData(object data)
    40 {
    41 .....
    42 .....
    43 // THE NEXT LINE THROWS EntityException "The underlying provider failed on Commit."
    44 // Inner Exception - The transaction operation cannot be performed because there are pending requests working on this transaction.
    45 //

    46 Context.SaveChanges();
    47 }
    48 }
    49
      

     

     

     

    Sunday, July 26, 2009 7:15 PM