public List <AuthorizationDatabaseTable> LoadViews()
        {
            if (_views != null)
            {
                return(_views);
            }

            using (var connection = _databaseConnectionProvider.CreateConnection(_connectionString))
            {
                connection.Open();

                using (var dr = new DatabaseReader(connection))
                {
                    dr.CommandTimeout = 60;

                    _views = dr.AllViews().Select(
                        v => new AuthorizationDatabaseTable()
                    {
                        SchemaOwner = v.SchemaOwner,
                        Name        = v.Name,
                        Columns     = v.Columns.Select(x => new AuthorizationDatabaseColumn()
                        {
                            DbDataType   = x.DbDataType,
                            IsPrimaryKey = x.IsPrimaryKey,
                            Length       = x.Length,
                            Name         = x.Name,
                            Nullable     = x.Nullable,
                            Precision    = x.Precision,
                            Scale        = x.Scale
                        })
                    }).ToList();

                    var dataTupleTable = dr.Table("EducationOrganizationIdToEducationOrganizationId");

                    _views.Add(new AuthorizationDatabaseTable()
                    {
                        SchemaOwner = dataTupleTable.SchemaOwner,
                        Name        = dataTupleTable.Name,
                        Columns     = dataTupleTable.Columns.Select(x => new AuthorizationDatabaseColumn()
                        {
                            DbDataType   = x.DbDataType,
                            IsPrimaryKey = x.IsPrimaryKey,
                            Length       = x.Length,
                            Name         = x.Name,
                            Nullable     = x.Nullable,
                            Precision    = x.Precision,
                            Scale        = x.Scale
                        })
                    });
                }

                return(_views);
            }
        }
Ejemplo n.º 2
0
        public List <DatabaseView> LoadViews()
        {
            if (_views != null)
            {
                return(_views);
            }

            using (var connection = _databaseConnectionProvider.CreateConnection(_connectionString))
            {
                connection.Open();

                using (var dr = new DatabaseReader(connection))
                {
                    dr.CommandTimeout = 60;
                    _views            = dr.AllViews().ToList();
                }
            }

            return(_views);
        }