views:

191

answers:

2

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?

+1  A: 

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.

Ben Aston
+1  A: 

As Ben said, you can use qualified type names.

However, the usual practice in NHibernate is to put the mapping for each class in a separate file, which makes it easier to maintain.

Personally, I sometimes group related classes in the same file, but that's it (like XYHeader and XYDetail).

For types coming from different assemblies (which usually imply different subdomains), I even use separate projects.

Diego Mijelshon