Yesterday, the configuration file of powerdesigner was modified to implement special C # Code After the requirements are generated, I suddenly thought: it would be nice to generate a map file directly in powerdesigner.
I tried it for a while in the afternoon and found that it is completely feasible. The specific method is
Add an item under profile \ classifier \ generated files, such as HBM. XML, which is set
File Name: % topcontainercode %. HBM. xml
Note:
. If (% isgenerated %)
. Set_object (_ usingcontext, new)
[\ % Nhebernatehead % \ n] \
% Nhebernatebody % \ n
% Nhebernatefoot %
. Endif
Set the value of the variable. For example, set % nhebernatebody %:
<Class name = "% myclasspathname %. % parent. PATH %, % myclasspathname %" table = "% parent. PATH %"> \ n
. Foreach_item (attributes)
. If (% code % = % myprimarykey %)
<ID name = "% code %" column = "% code %" type = "string">
<Generator class = "assigned"/>
</ID> \ n
. Endif
. If (% datatype % = "string ")
<Property name = "% code %" column = "% code %" type = "string"/> \ n
. Endif
. If (% datatype % = "int ")
<Property name = "% code %" column = "% code %" type = "int32"/> \ n
. Endif
. Next
</Class>
(You can add the data type conversion part by yourself)
After setting, add references to these files in the project file.
Set profile \ basepackage \ Templates \ visualstudio. Net \ projectsourcefiles:
. // Declare classifiers of the package
. Foreach_item (classifiers, % isshortcut % = false)
. If (% isselected %) and (% isinner % = false)
<File
Relpath = "% sourcefilepath %"
Subtype = "code"
Buildaction = "compile"
/>
<File
Relpath = "% parent. PATH % \\% topcontainercode %. HBM. xml"
Buildaction = "embeddedresource"
/>
. Endif (\ n)
. Next
. // Declare classifiers of the subpackages
. Foreach_item (packages, % isshortcut % = false)
. If (% isassembly % = false)
% Projectsourcefiles %
. Endif
. Next
Done!