Pergunta

I have a Fluent NHibernate Mapping that maps a property of a class to use the NHibernate XDocType

  Map(x => x.Content)
            .Not.Nullable()
            .CustomType(typeof (XDocType));

I'm using this as the table column in Sql 2008 db is of type XML.

Currently I'm trying to write some Unit/Integration Tests using Sql CE which does not support the XML Column type.

Is there a simple way when I'm spinning up my Session Factory to say I would like to override the Content column mapping to use a supported type.

An example of how I'm currently spinning up the session factory is below

var sessionFactory = Fluently.Configure()                                 
                                .Database(MsSqlCeConfiguration.Standard.ShowSql().ConnectionString(connectionString))
                                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<MyAssembly>())
                                .ExposeConfiguration((c) =>
                                                         {
                                                             sessionConfig = c;
                                                             new SchemaExport(c).Create(false, true);
                                                         })                                    
                                .BuildSessionFactory();

Thanks.

Foi útil?

Solução

You should extend the MsSqlCeDialect or MsSqlCe40Dialect and add:

RegisterColumnType(DbType.Xml, "NTEXT");

That will use the NTEXT SQL type for XDocType/XmlDocType properties.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top