tags:

views:

10

answers:

1

Is there a way to map an XML field using Fluent Nhibernate.

If you have an XML field in MSSQL database, how would you Map using Fluent NHibnernate?

Example

        Table("Address");
        LazyLoad();
        Id(x => x.AddressId).GeneratedBy.HiLo("1000");
        Map(x => x.AddressLine1).Length(100).Not.Nullable();
        Map(x => x.AddressLine2).Length(100).Not.Nullable();
        Map(x => x.AddressLine3).Length(100).Not.Nullable();
        References(x => x.AddressPerson).Column("PersonId");
        Map(x => x.ReferenceXML)//Map to XML Type in my Domain
A: 

Ayende has some sample code that shows how one can use the XML SQL Server type here. It uses XML-based NH mapping. To see how to implement IUserType in fluent nHibernate see this page or this page to see how to implement a fluent nh "convention".

Tahbaza