Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem with get() method!

Problem with get() method!

Scheduled Pinned Locked Moved C#
helpquestion
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LAPEC
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • L LAPEC

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      It means there's no method name "get" on the ISessionFactory. Is the code from Java? Try (ISessionFactory)sessionFactoryMap[configFile];

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      L 1 Reply Last reply
      0
      • L Lost User

        It means there's no method name "get" on the ISessionFactory. Is the code from Java? Try (ISessionFactory)sessionFactoryMap[configFile];

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        L Offline
        L Offline
        LAPEC
        wrote on last edited by
        #3

        Thanks for your help a lot, and actually it is from java code

        L 1 Reply Last reply
        0
        • L LAPEC

          Thanks for your help a lot, and actually it is from java code

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You're welcome :java:

          L 2 Replies Last reply
          0
          • L Lost User

            You're welcome :java:

            L Offline
            L Offline
            LAPEC
            wrote on last edited by
            #5

            Can I please ask you for another help if you don't mind

            1 Reply Last reply
            0
            • L Lost User

              You're welcome :java:

              L Offline
              L Offline
              LAPEC
              wrote on last edited by
              #6

              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;
              }
              }
              }

              L 1 Reply Last reply
              0
              • L LAPEC

                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;
                }
                }
                }

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                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[^]

                L 1 Reply Last reply
                0
                • L Lost User

                  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[^]

                  L Offline
                  L Offline
                  LAPEC
                  wrote on last edited by
                  #8

                  It is NHibernate

                  L 1 Reply Last reply
                  0
                  • L LAPEC

                    It is NHibernate

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    Google for some C# example with NHibernate doing stuff with ISession and OpenSession; there's not much examples, but any that works would do :)

                    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups