Use powerdesigner to generate the nhebernate Map File

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.