Problem with get() method!
-
Hello everyone I'm trying to solve this problem but i can't get it. Maybe someone can help me solve this problem please... When I compile the error says:
Quote:
Error 'System.Collections.Generic.Dictionary' does not contain a definition for 'get' and no extension method 'get' accepting a first argument of type 'System.Collections.Generic.Dictionary' could be found (are you missing a using directive or an assembly reference?)
protected static ISessionFactory getSessionFactory(string configFile)
{
if (null == configFile)
{
if (sessionFactory == null)
{
throw new Exception("The session factory has not been initialized (or an error occurred during initialization)");
}
else
{
return sessionFactory;
}
}
else
{
if (sessionFactoryMap == null)
{
throw new Exception("The session factory for '" + configFile + "' has not been initialized (or an error occurred during initialization)");
}
else
{
ISessionFactory sf = (ISessionFactory) sessionFactoryMap.get(configFile);
if (null == sf)
{
throw new Exception("The session factory for '" + configFile + "' has not been initialized (or an error occured during initialization)");
}
else
{
return sf;
}
}
}
}Thanks in advance
-
Hello everyone I'm trying to solve this problem but i can't get it. Maybe someone can help me solve this problem please... When I compile the error says:
Quote:
Error 'System.Collections.Generic.Dictionary' does not contain a definition for 'get' and no extension method 'get' accepting a first argument of type 'System.Collections.Generic.Dictionary' could be found (are you missing a using directive or an assembly reference?)
protected static ISessionFactory getSessionFactory(string configFile)
{
if (null == configFile)
{
if (sessionFactory == null)
{
throw new Exception("The session factory has not been initialized (or an error occurred during initialization)");
}
else
{
return sessionFactory;
}
}
else
{
if (sessionFactoryMap == null)
{
throw new Exception("The session factory for '" + configFile + "' has not been initialized (or an error occurred during initialization)");
}
else
{
ISessionFactory sf = (ISessionFactory) sessionFactoryMap.get(configFile);
if (null == sf)
{
throw new Exception("The session factory for '" + configFile + "' has not been initialized (or an error occured during initialization)");
}
else
{
return sf;
}
}
}
}Thanks in advance
-
-
In this part of code im having error on get() and set() method...
Quote:
protected static ISession getSession(string configFile, bool createNew)
{
if (createNew)
{
return getSessionFactory(configFile).OpenSession();
}
else
{
if (null == configFile)
{
if (null == sessions)
{
sessions = new ThreadLocal();
}
ISession session = sessions.get();
if (null == session || !session.IsOpen)
{
session = getSessionFactory(null).OpenSession();
session.set(session);
}
return session;
}
else
{
if (null == mappedSessions)
{
mappedSessions = new ThreadLocal();
}
Dictionary map = mappedSessions.get();
if (null == map)
{
map = new Dictionary(1);
mappedSessions.set(map);
}
ISession session = map[configFile];
if (null == session || !session.IsOpen)
{
session = getSessionFactory(configFile).OpenSession();
map.Add(configFile, session);
}
return session;
}
}
} -
In this part of code im having error on get() and set() method...
Quote:
protected static ISession getSession(string configFile, bool createNew)
{
if (createNew)
{
return getSessionFactory(configFile).OpenSession();
}
else
{
if (null == configFile)
{
if (null == sessions)
{
sessions = new ThreadLocal();
}
ISession session = sessions.get();
if (null == session || !session.IsOpen)
{
session = getSessionFactory(null).OpenSession();
session.set(session);
}
return session;
}
else
{
if (null == mappedSessions)
{
mappedSessions = new ThreadLocal();
}
Dictionary map = mappedSessions.get();
if (null == map)
{
map = new Dictionary(1);
mappedSessions.set(map);
}
ISession session = map[configFile];
if (null == session || !session.IsOpen)
{
session = getSessionFactory(configFile).OpenSession();
map.Add(configFile, session);
}
return session;
}
}
}According to MSDN, the ThreadLocal[^] class has a "Value" property that looks promising. ISessions session = sessions.Value? Properties in C# do not need to explicitly call a getter/setter. What kind of session is being created? Google is betting on NHibernate :)
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
According to MSDN, the ThreadLocal[^] class has a "Value" property that looks promising. ISessions session = sessions.Value? Properties in C# do not need to explicitly call a getter/setter. What kind of session is being created? Google is betting on NHibernate :)
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]