What is the reason of “Transaction context in use by another session”

前端 未结 6 567
孤独总比滥情好
孤独总比滥情好 2020-12-10 02:42

I\'m looking for a description of the root of this error: \"Transaction context in use by another session\".

I get it sometimes in one of my unittests so I can\'t pr

6条回答
  •  攒了一身酷
    2020-12-10 03:23

    How I'd deal with that issue when building Linq statements with mutlipe objects is to have a constructor for each class that takes in a data context and a coresponding GetDataContext() method in each class. when combining classes, I'd new up the class instances passing in the first class's GetContext()

      public class CriterionRepository : ICriterionRepository
        {
    
            private Survey.Core.Repository.SqlDataContext _context = new Survey.Core.Repository.SqlDataContext();
    
            public CriterionRepository() { }
    
            public CriterionRepository(Survey.Core.Repository.SqlDataContext context)
            {            
                _context = context;
            }
    
    ...
    
    
            public Survey.Core.Repository.SqlDataContext GetDataContext()
            {
                return _context;
            }
    
    }
    

提交回复
热议问题