NHibernate.Mapping.Attributes - Support ImportAttribute when serializing an assembly
Description
Environment
Activity

Pierre Henri Kuaté September 28, 2007 at 8:59 AM
Done. Cf the documentation.

Pierre Henri Kuaté September 26, 2007 at 11:48 PM
Hmm... From this point of view, it makes sense to support the ImportAttribute.
Here is an easy solution that you can :
Create a class inheriting from HbmSerializer
Override the Serialize(assembly) methods
Copy their code
Before starting to add the classes mapping, do a "foreach type in assembly, if type has ImportAttribute, add it to the xml;"
Instantiate this class (instead of using HbmSerializer.Default)
That's it
I will work on updating NHMA as soon as possible.

Christoph Wienands September 26, 2007 at 8:15 PM
I understand that the Import element is directly under the "hibernate-mapping".
However, I'm currently creating a number of strongly-typed query result object. Just like with the ClassAttributes I think it would make sense ot be able to annotate those classes with an ImportAttribute. The attrbiute could derive the proper type name automatically or at least I could provide a typeof() operator.
With the current situation I have to use two different approaches: Attributes and additional imports using an XML file. Therefore, e.g. class name refactorings will break the import XML files.
Just my two cents why I think ImportAttributes on classes would make sense
Christoph

Pierre Henri Kuaté July 13, 2007 at 11:53 PM
NHMA is generated and all kind of mapping have their attribute.
However, the ImportAttribute (and few others) are not used when generating classes mappings (because they are not part of classes mappings).
They may still be useful because you can extend NHMA so that it uses these attributes...

Saravanan K July 13, 2007 at 9:35 AM
Now I am able to do the import using the .hbm.xml file. But what is the use of ImportAttribute of Nhibernate.Mapping.Attribute?
I used the attribute import in my business entity class like below
[Import(0, Class = "Saran.Application.Silvereye.BusinessEntities.IEmployee,Saran.Application.Silvereye.BusinessEntities")]
But when I used the HBMSerilizer to generate the hbm mapping stream, <Import .../> is not getting added.
Can some one resolve this issue?. My work is affected because of this issue.