Yes it is.

This method in Configuration class is available since NH1.2.0 or so
public Mappings CreateMappings(Dialect.Dialect dialect)

With the Mappings class you can add new object and/or
public IEnumerable<Table> IterateTables
public IEnumerable<Mapping.Collection> IterateCollections
public IDictionary<string, FilterDefinition> FilterDefinitions

With the Table class
public virtual IEnumerable<Index> IndexIterator
public IEnumerable<ForeignKey> ForeignKeyIterator
public virtual IEnumerable<UniqueKey> UniqueKeyIterator
public virtual PrimaryKey PrimaryKey { get; set; }
public virtual IEnumerable<Column> ColumnIterator
public string SqlCreateString(Dialect.Dialect dialect, IMapping p, string
defaultCatalog, string defaultSchema)
public string[] SqlAlterStrings(Dialect.Dialect dialect, IMapping p,
ITableMetadata tableInfo, string defaultCatalog,
                                string defaultSchema)

and so on.

Do you need something else ?


On Fri, Aug 13, 2010 at 11:43 PM, Patrick Earl <[email protected]> wrote:

> Indeed, it may be unneeded.  Maybe I should be posting to the users
> list instead.
>
> We use ActiveRecord to initialize the database, and then to access all
> the table and foreign key information, we use the following code:
>
>            NHibernate.Cfg.Configuration configuration =
> sessionFactoryHolder.GetAllConfigurations()[0];
>            configuration.SecondPassCompile();
>            Objects = new
> MetaObjectCollection(configuration.TableMappings,
> configuration.mapping);
>
> The MetaObjectCollection constructor then accesses the list of tables
> from TableMappings and generates its own view of the database schema
> from that.  The mapping is used in a call to
> Column.GetSqlTypeCode(mapping).
>
> Basically, we need a mechanism to access what NHibernate thinks the
> database should look like... all the tables, columns, foreign keys,
> primary keys, etc.
>
> Does something like this already exist?
>
>        Patrick Earl
>
> On Aug 13, 11:18 am, Fabio Maulo <[email protected]> wrote:
> > Try to explain because, even if there is no problem to make something
> > public,
> > to me your patch seems unneeded.
> >
> >
> >
> > On Fri, Aug 13, 2010 at 1:32 PM, Patrick Earl <[email protected]> wrote:
> > > We have been maintaining an internal patch to NHibernate for quite
> > > some time, and I'd ultimately like to be able to run on an unpatched
> > > version of NHibernate.  The internal patch we use allows us to access
> > > the mapping schema that NHibernate generates.  This allows us to build
> > > our own enhanced system for applying schema updates to the database.
> > > I'd submit a patch, but I'm not really sure in which direction to go.
> > > I'd love some feedback on how this might be done.
> >
> > > Here's what our internal patch does to Configuration.cs:
> >
> > > -               private IMapping mapping;
> > > +               public IMapping mapping;
> >
> > > -               private ICollection<Table> TableMappings
> > > +               public ICollection<Table> TableMappings
> >
> > > -               private void SecondPassCompile()
> > > +               public void SecondPassCompile()
> >
> > > Looking forward to hearing people's thoughts.
> >
> > >        Patrick Earl
> >
> > --
> > Fabio Maulo
>



-- 
Fabio Maulo

Reply via email to