Iam trying to call call a method which having an OpenSession but its ending up with an error
"No session bound to the current HttpContext" in CurrentSesions following line
The following is the full code of CurrentSessionCode:_currentSession = Instance.GetSessionFactory().GetCurrentSession();
and this methods are in a class names "WigleSessionManager" and its constructer is the followingCode:public static ISession CurrentSession { get { ISession _currentSession = null; if (System.Web.HttpContext.Current != null) { _currentSession = Instance.GetSessionFactory().GetCurrentSession(); } else { _currentSession = SessionFactory.OpenSession(); } return _currentSession; } }
here in sessionFactory object is showing ENtityFetchCount,EntityLoadCount and Entity names all 0...Code:private WigleSessionManager() { Configuration configuration = new Configuration(); configuration.Configure(); string[] Files; string src = System.Configuration.ConfigurationSettings.AppSettings["ComponentDirectory"]; if (string.IsNullOrEmpty(src)) { throw new Exception("System Error: ComponentDirectory key not defined in web.config"); } Files = Directory.GetFiles(src, "*Entities.dll"); foreach (string Element in Files) { try { Assembly SampleAssembly; SampleAssembly = Assembly.LoadFrom(Element); configuration.AddAssembly(SampleAssembly); } catch (Exception) { } } sessionFactory = configuration.BuildSessionFactory(); }




Reply With Quote