private List <TableInformationModel> GetTablesFromRepository(DatabaseInfo dbInfo)
        {
            if (dbInfo.DatabaseType == DatabaseType.Npgsql)
            {
                return(EnvDteHelper.GetNpgsqlTableNames(dbInfo.ConnectionString));
            }

            if (dbInfo.DatabaseType == DatabaseType.Mysql)
            {
                return(EnvDteHelper.GetMysqlTableNames(dbInfo.ConnectionString));
            }

            using (var repository = RepositoryHelper.CreateRepository(dbInfo))
            {
                var allPks    = repository.GetAllPrimaryKeys();
                var tableList = repository.GetAllTableNamesForExclusion();
                var tables    = new List <TableInformationModel>();

                foreach (var table in tableList)
                {
                    var hasPrimaryKey = allPks.Any(m => m.TableName == table);
                    tables.Add(new TableInformationModel(table, hasPrimaryKey));
                }
                return(tables);
            }
        }
Exemple #2
0
        private List <string> GetTablesFromRepository(DatabaseInfo dbInfo)
        {
            if (dbInfo.DatabaseType == DatabaseType.Npgsql)
            {
                return(EnvDteHelper.GetNpgsqlTableNames(dbInfo.ConnectionString));
            }

            using (var repository = RepositoryHelper.CreateRepository(dbInfo))
            {
                var allPks    = repository.GetAllPrimaryKeys();
                var tableList = repository.GetAllTableNamesForExclusion();
                var tables    = new List <string>();

                foreach (var table in tableList)
                {
                    if (allPks.Where(pk => pk.TableName == table).Count() > 0)
                    {
                        tables.Add(table);
                    }
                }
                return(tables);
            }
        }