Esempio n. 1
0
        void OpenDatabase()
        {
            try
            {
                // Create our index
                var index = new Database.Index(name: _indexName, version: "1.0", map: (document, addIndexRow) =>
                {
                    // This index will have a row for each document, keyed by the "word", and having a value of the "definition"
                    if (document.Properties.TryGetValue(_wordKey, out object word))
                    {
                        addIndexRow(word, document.Properties[_definitionKey]);
                    }
                });

                // Creates a dabase configuration with default name and location, and the provided index(s)
                _databaseConfig = new Database.OpenDatabaseConfiguration(indexes: new List <IIndexer> {
                    index
                });

                // Open the database
                _database = Database.Open(configuration: _databaseConfig, create: true);
            }
            catch (Exception error)
            {
                Console.WriteLine($"Error opening database: {error}");
            }
        }
Esempio n. 2
0
 private void OpenDatabase()
 {
     try
     {
         // Open the database
         _config   = Database.OpenDatabaseConfiguration.Default;
         _database = Database.Open(configuration: _config, create: true);
     }
     catch (Exception error)
     {
         Console.WriteLine($"Error opening database: {error}");
     }
 }
        private async Task OpenDatabase()
        {
            try
            {
                _databaseConfig = Database.OpenDatabaseConfiguration.Default;

                // Clear database so we can start from fresh, then open the database
                await Database.Delete(_databaseConfig);

                _database = Database.Open(configuration: _databaseConfig, create: true);

                // set this to replication delegate, so we can show replication status information
                // see ReplicationStatusDelegate extension below for these methods.
                _database.ReplicationStatusDelegate = this;
            }
            catch (Exception error)
            {
                Console.WriteLine($"Error opening database: {error}");
            }
        }