Since I was struggling to find a solution, I would like to share my solution here (with XDocument instead of XElement, but at least for XML columns).
First create this agreement;
using System.Xml.Linq; using FluentNHibernate.Conventions; using FluentNHibernate.Conventions.AcceptanceCriteria; using FluentNHibernate.Conventions.Inspections; using FluentNHibernate.Conventions.Instances; public class XmlTypeConvention : IUserTypeConvention { public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria) { criteria.Expect(x => x.Type == typeof(XDocument)); } public void Apply(IPropertyInstance instance) { instance.CustomType<NHibernate.Type.XDocType>(); } }
Then be sure to add an agreement;
Conventions.Add<XmlTypeConvention>();
Now, if your domain object has an XDocument property, it will turn into an XML column in the database.
source share