Пример #1
0
 private async Task <IEnumerable <DataBaseModel> > GetConnectionDatabasesAsync(ConnectionModel con)
 {
     try {
         return(await Task <IEnumerable <DataBaseModel> > .Factory.StartNew(() => {
             using (SqlConnection connection = new SqlConnection(con.BuildConnection())) {
                 connection.Open();
                 const string sql = @"SELECT name FROM sys.Databases WHERE name not in ('master','tempdb','model','msdb')";
                 return connection.Query <DataBaseModel>(sql);
             }
         }));
     } catch (Exception ex) {
         Error = ex.Message;
         CancelationSource.Cancel();
         return(new List <DataBaseModel>());
     }
 }