Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Types from multiple assemblies and namespaces in nhibernate mapping files

You can specify the namespace and assembly to use types from at the top of HBM files:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyCorp.MyAssembly" namespace="MyCorp.MyAssembly.MyNamespace">

Can you use types from multiple assemblies / namespaces within the same mapping file, and if so what is the syntax for doing so?

like image 888
Ben Aston Avatar asked Apr 19 '10 16:04

Ben Aston


People also ask

What is the difference between NHibernate and fluent NHibernate?

Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents, you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

What is NHibernate in C#?

NHibernate is a mature, open source object-relational mapper for the . NET framework. It's actively developed, fully featured and used in thousands of successful projects. Easily map regular C# or VB.NET object models designed in Visual Studio.


1 Answers

You can remove the default assembly and namespace definitions from the top of the HBM file and then specify the fully qualified type names each time they occur in the mapping file as follows:

Namespace.TypeName,Assembly.Name

Not pretty, but it works.

like image 72
Ben Aston Avatar answered Sep 19 '22 17:09

Ben Aston