Source/Providers/NFX.MongoDB/MongoDBDataStoreBase.cs
/// <summary>
/// Gets appropriate database. It does not need to be disposed
/// </summary>
Gets appropriate database. It does not need to be disposed
Gets appropriate database . It does not need to be disposed
protected Database GetDatabase()
      {
        var cstring = m_ConnectString;
        var dbn = m_DatabaseName;
        var ctx = CRUDOperationCallContext.Current;
        if (ctx!=null)
        {
          if (ctx.ConnectString.IsNotNullOrWhiteSpace()) cstring = ctx.ConnectString;
          if (ctx.DatabaseName.IsNotNullOrWhiteSpace()) dbn = ctx.DatabaseName;
        }
        var lactxt = cstring;
        if (lactxt!=null)
        {
          lactxt = lactxt.Trim();
          if (lactxt.StartsWith(MongoClient.CONFIG_CS_ROOT_SECTION + "{"))
          {
            var root = lactxt.AsLaconicConfig();
            if (root!=null)
            {
              cstring = root.AttrByName(MongoClient.CONFIG_CS_SERVER_ATTR).Value;
              if (dbn.IsNullOrWhiteSpace())
                dbn = root.AttrByName(MongoClient.CONFIG_CS_DB_ATTR).Value;
            }
          }
        }
        var server = MongoClient.Instance[ new NFX.Glue.Node(cstring)];
        var database = server[dbn];
        return database;
      }
protected Database GetDatabase ( ) { var cstring = m_ConnectString ; var dbn = m_DatabaseName ; var ctx = CRUDOperationCallContext . Current ; if ( ctx != null ) { if ( ctx . ConnectString . IsNotNullOrWhiteSpace ( ) ) cstring = ctx . ConnectString ; if ( ctx . DatabaseName . IsNotNullOrWhiteSpace ( ) ) dbn = ctx . DatabaseName ; } var lactxt = cstring ; if ( lactxt != null ) { lactxt = lactxt . Trim ( ) ; if ( lactxt . StartsWith ( MongoClient . CONFIG_CS_ROOT_SECTION + " " ) ) { var root = lactxt . AsLaconicConfig ( ) ; if ( root != null ) { cstring = root . AttrByName ( MongoClient . CONFIG_CS_SERVER_ATTR ) . Value ; if ( dbn . IsNullOrWhiteSpace ( ) ) dbn = root . AttrByName ( MongoClient . CONFIG_CS_DB_ATTR ) . Value ; } } } var server = MongoClient . Instance [ new NFX . Glue . Node ( cstring ) ] ; var database = server [ dbn ] ; return database ; }
Gets appropriate database.
Gets appropriate database .
//cstring may either have server cs, or contain laconic config  mongo{server='' database=''} //Try to override from the context //2. try to parse as laconic //quick reject filter