Amaro,
Could I get your feedback on this Gist
<https://gist.github.com/jeffreyabecker/4d379e13c165df8240ce>of how to
extract the schema from Configuration?
On Tuesday, March 10, 2015 at 4:50:03 PM UTC-4, Jeffrey Becker wrote:
>
> I remember having to modify the Enhanced stuff but I've never seen anyone
> use that so I'll just skip it.
>
> On Tuesday, March 10, 2015 at 3:50:45 PM UTC-4, Amro El-Fakharany wrote:
>>
>> 1) A PersistentClass holds a couple of Property iterators. I would first
>> try “SubclassPropertyClosureIterator” (but I’m not really sure!).
>>
>> Each Property instance holds a collection of Column objects called
>> “ColumnIterator”.
>>
>> To get the type of a column you just call: column.GetSqlTypeCode(mapping).
>>
>> You get that “mapping” argument by calling BuildMapping() on a
>> Configuration instance which you should do before accessing ClassMappings
>> for the first time.
>>
>> Here is a pseudo code example:
>>
>> var mapping = nhConfiguration.BuildMapping()
>>
>> foreach(var pc in nhConfiguration.ClassMappings)
>>
>> {
>>
>> foreach(var property in pc.SubclassPropertyClosureIterator)
>>
>> {
>>
>> foreach(var col in property.ColumnIterator)
>>
>> var dbType = col.GetSqlTypeCode(mapping).DbType
>>
>> }
>>
>> }
>>
>>
>>
>> 2) As far as I can tell, the only true black box identifier is
>> TableGenerator.
>>
>> If I’m not completely mistaken the rest should be accessible through
>> PersistenceClass.IdentifierProperty.ColumnIterator
>>
>>
>>
>> Amro
>>
>>
>>
>> *Von:* [email protected] [mailto:
>> [email protected]] *Im Auftrag von *Jeffrey Becker
>> *Gesendet:* Dienstag, 10. März 2015 19:40
>> *An:* [email protected]
>> *Betreff:* Re: [nhibernate-development] Re: Migrations Status & Feedback
>> request
>>
>>
>>
>> Amaro, I started going down the path you suggested and I'm running into
>> some pretty big road blocks.
>>
>>
>>
>> 1) Resolving the type of a column requires access to the mapping which is
>> private to Configuration
>>
>> 2) PersistentIdentifiers are black-boxes which keep their params private
>> and spit out some sql.
>>
>>
>>
>> These are both pretty big blockers which my code addresses through the
>> operations framework. I'm definitely much more interested in using
>> FluentMigrator to do the actual migrations but at this point NHibernate
>> doesn't expose the information FluentMigrator needs.
>>
>> On Monday, February 16, 2015 at 9:15:49 AM UTC-5, Amro El-Fakharany wrote:
>>
>> Take a look at the implementation of IterateGenerators in the
>> Configuration class (the last method in Configuration.cs).
>>
>> It shows how to get hold of identifier generators.
>>
>>
>>
>> As for auxiliary objects the easiest way I can ad hoc think of would be
>> to subscribe to one of the Events BeforeBindMapping or AfterBindMapping of
>> Configuration.
>>
>> Both events gets HbmMapping as a property of the argument
>> BindMappingEventArgs.
>>
>> In the event handler you just iterate over HbmMapping.DatabaseObjects.
>>
>> I won’t overestimate the importance of auxiliary objects though.
>>
>>
>>
>>
>>
>> *Von:* [email protected] [mailto:
>> [email protected]] *Im Auftrag von *Jeffrey Becker
>> *Gesendet:* Montag, 16. Februar 2015 14:26
>> *An:* [email protected]
>> *Betreff:* Re: [nhibernate-development] Re: Migrations Status & Feedback
>> request
>>
>>
>>
>> I did look into using the PersistentClass property but that doesn't seem
>> to include information about identifier generators or auxiliary db objects.
>> My first thought with this was to simply spider configuration and spit out
>> a fluent migrator based class. I went down the whole operations framework
>> path after concluding that all the mapping information I needed just wasn't
>> available.
>>
>> On Saturday, February 14, 2015 at 9:54:00 AM UTC-5, Amro El-Fakharany
>> wrote:
>>
>> There is no need to read XML files or interpret mapping-by-code stuff.
>> All of the required mapping information ends up in PersistentClass which
>> is exposed in Configuration through the Enumerable Property ClassMappings
>> if I remember correctly.
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nhibernate-development" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nhibernate-development" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
---
You received this message because you are subscribed to the Google Groups
"nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.