Search code examples
nhibernatefluent-nhibernatexmldocument

Fluent NHibernate Automap error while mapping XmlDocument Column


I am new to NHibernate and am facing some issues with Fluent NHibernate automap.

I am using Nhibernate 3.3.3.400, Fluent Nhibernate 1.3.0.733 Automapper 2.2.1

I have a column in Database which is of type Xml. When I try to create a ma mapping column it give me the following error.

An association from the table Product refers to an unmapped class: System.Xml.XmlDocument

Following is the code I am trying to implement.

using System.Collections.Generic;
using System.Xml;

//using System.Xml.Linq;

namespace Examples.FirstAutomappedProject.Entities
{
    public class Product
    {
        public virtual int Id { get; protected set; }
        public virtual string Name { get; set; }
        public virtual double Price { get; set; }
        public virtual Location Location { get; set; }
        public virtual IList<Store> StoresStockedIn { get; set; }
        public virtual XmlDocument SalesRange { get; set; }

        public Product()
        {
            StoresStockedIn = new List<Store>();
        }
    }
}

I have been struggling for a couple of days now anhy help or samples would be greatly appreciated.


Solution

  • it seems it FNH will not map it on it's own. you'll need a Override there

    Map(x => x.SalesRange).CustomType<NHibernate.Type.XmlDocType>();