zoukankan      html  css  js  c++  java
  • Subsonic 3, T4 Templates, SQLite

    I want to start with how the templates will work out in an actual Visual Studio project/solution. T4 templates have a *.tt extension. You can compartmentalize code by splitting it into different include files. That's what all the *.ttinclude files are.

    Make sure that the project where the templates are, have a reference to Subsonic.Core.

    You will need five files:

    • ActiveRecord.tt
    • Context.tt
    • Settings.ttinclude
    • SQLite.ttinclude
    • App.config

    The first file you will need to configure is App.config. You will need to setup your connection string to your SQLite database.

    Just make sure that the values for providerName and connectionString are correct. Now remember the value for the name attribute, because we will be using it next. We will now edit the Settings.ttinclude file.

    There are four things that you will want to change. I have already changed them here for WheelMUD related settings.

    • Namespace - This is the namespace where all of the code will fall into.
    • ConnectionStringName - This is the value that we set up in the App.config file. This tells the templates what and where the database is.
    • DatabaseName - This is something that the templates will use internally.
    • ExcludeTables - This is used to exclude tables from getting processed.

    Now we are set to run the templates. To run them, right click on any of the files with a *.tt extension. You will see a "Run Custom Tool" entry in the context menu.

    Make sure that you run Context.tt, before you run ActiveRecord.tt. ActiveRecord.cs references code in Context.cs. The first time you run a template you will see this warning dialog:

    I checked the "Do not show this message again" box, so that this wouldn't appear every time I saved or ran the temaplate. I suggest you do the same.

    Once you run the ActiveRecord.tt template, you will see this:

    I changed the templates a bit so that they generate code compliant to our standards. I zipped everything that is needed to make this templates run. This means that the latest version of Subsonic 3 is included as an assembly as well.

  • 相关阅读:
    汇编中的String
    对于C语言可移植性的思考【转】【补充】
    AT&T Mnemonic Conventions(AT&T汇编助记法的规则)
    Macro和Procedure的比较(汇编中的宏与函数)
    File Descriptor和Sys_call number
    #include <sys/types.h>在哪里?
    IIS7 与 WCF 问题总结
    非常不错的WCF入门文章,来自Artech
    WCF 部署问题 小总结 (HTTP 不能注册的解决方法)
    IIS7 aspx出现500.21错误
  • 原文地址:https://www.cnblogs.com/leeolevis/p/1894775.html
Copyright © 2011-2022 走看看