public bool CheckIfDBExists(string dbName) { List <string> dbNames = _mongoDbClient.ListDatabaseNames().ToList(); if (dbNames != null && dbNames.Count > 0 && dbNames.Where(x => x.ToLower() == dbName.ToLower()).Any()) { return(true); } return(false); }
private void SeedMongo() { if (_clientMongo.ListDatabaseNames().ToList().Any(nome => nome == _mongoDbConfiguracao.DatabaseName)) { return; } ObtenhaColecao <Usuario>().InsertOne(new Usuario() { Login = "******", Senha = "talentosmaxima" }); ObtenhaColecao <Produto>().InsertMany(new List <Produto>() { new Produto() { Codigo = "8689", Nome = "Fardo 6UN Coca-Cola 600ml", PrecoUnitario = (decimal)17.34, ImagemUrl = "http://localhost:4200/assets/icones/foto-coca-cola.png" }, new Produto() { Codigo = "8254", Nome = "Fardo 6UN Fanta 600ml", PrecoUnitario = (decimal)16.64, ImagemUrl = "http://localhost:4200/assets/icones/foto-fanta.png" }, }); ObtenhaColecao <Cliente>().InsertMany(new List <Cliente>() { new Cliente() { Codigo = "1", Nome = "Cliente 1" }, new Cliente() { Codigo = "2", Nome = "Cliente 2" }, new Cliente() { Codigo = "3", Nome = "Cliente 3" }, }); }
public IAsyncCursor <string> ListDatabaseNames( CancellationToken cancellationToken = default(CancellationToken)) { return(wrapped.ListDatabaseNames(cancellationToken)); }
public ActionResult <IEnumerable <string> > Get() { return(_mongoClient.ListDatabaseNames().ToList()); }
public IEnumerable <string> GetDatabases() => _client.ListDatabaseNames().ToList();
/// <summary> /// 异步获取mongo所有database /// </summary> /// <param name="connectionString">连接字符串,格式:mongodb://ip:port</param> /// <returns></returns> public static Task <List <string> > ListDataBasesAsync(string connectionString) { IMongoClient mongoClient = GetMongodbClient(connectionString); return(mongoClient.ListDatabaseNames().ToListAsync()); }
public IAsyncCursor <string> ListDatabaseNames(CancellationToken cancellationToken = default) { return(_client.ListDatabaseNames(cancellationToken)); }
private bool DoesDatabaseExist(string database) { var List = _client.ListDatabaseNames().ToList(); return(List.Contains(database)); }
public async Task <List <string> > GetMongoCollections() { return(await _mongoClient.ListDatabaseNames().ToListAsync()); }