public ArangoXmlRepository(IServiceProvider services, ILoggerFactory loggerFactory, string database, string collection, ArangoContext context) { if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _logger = loggerFactory.CreateLogger <ArangoXmlRepository>(); _services = services ?? throw new ArgumentNullException(nameof(services)); _database = database; _collection = collection; _context = context ?? services.GetRequiredService <ArangoContext>(); try { if (!_context.ExistDatabaseAsync(_database).Result) { _context.CreateDatabaseAsync(_database).Wait(); } var collections = _context.ListCollectionsAsync(_database).Result; if (!collections.Contains(collection)) { _context.CreateCollectionAsync(_database, _collection, ArangoCollectionType.Document).Wait(); } } catch (Exception e) { var logger = _logger; logger?.LogError(e, e.Message); } }
public ArangoSerilogSink( ArangoContext arango, string database = "logs", string collection = "logs", int batchPostingLimit = DefaultBatchPostingLimit, TimeSpan?period = null) : base(batchPostingLimit, period ?? DefaultPeriod) { _arango = arango; _database = database; _collection = collection; try { if (!arango.ExistDatabaseAsync(_database).Result) { _arango.CreateDatabaseAsync(_database).Wait(); _arango.CreateCollectionAsync(_database, _collection, ArangoCollectionType.Document).Wait(); } } catch (Exception) { // } }
/// <summary> /// Initialisiert eine Datenbank und eine Collection für die Tests /// </summary> /// <returns></returns> public async Task InitializeAsync() { await Arango.CreateDatabaseAsync("test"); await Arango.CreateCollectionAsync("test", nameof(Project), ArangoCollectionType.Document); await Arango.CreateDocumentAsync("test", nameof(Project), new Project { Key = Guid.NewGuid(), Name = "A", Value = 1 }); }
/*[Fact] * public void Test5() * { * var test = Arango.AsQueryable<Project>("test").Where( x=> x.Value == 1 || x.Value == 2).ToList(); * }*/ public async Task InitializeAsync() { await Arango.CreateDatabaseAsync("test"); await Arango.CreateCollectionAsync("test", nameof(Project), ArangoCollectionType.Document); }