SubSonic 命令列參數及使用樣本

來源:互聯網
上載者:User

以下是SubSonic 命令列參數

sonic.exe v2.0.1.0 - Command Line Interface to SubSonic v2.0.1.0
Usage:   sonic command [options]
Sample:  sonic generate /server localhost /db northwind /out GeneratedFiles
Help:    sonic help
TIP:    SubSonic will read your App.Config or Web.Config - just select the project and run your command.

******************** Commands *********************************
version:        Scripts out the schema/data of your db to file
scriptdata:     Scripts the data to file for your database
scriptschema:   Scripts your Database schema to file
generate:       Generates output code for tables, views, and SPs
generatetables: Generates output code for your tables
generateODS:    Generates and ObjectDataSource controller for each table
generateviews:  Generates output code for your views
generatesps:    Generates output code for your SPs
editor:         Creates an Editor for a particular table

******************** Argument List ****************************
####### Required For all commands (these can be read from config files)
if you don't have a Web or App.config, these need to be set
/override       SubCommander won't try to find a config - instead it will use what you pass in
/server -       the database server - ALWAYS REQUIRED
/db -           the database to use

####### Other Commands (some may be required for specific commands)
/userid -       the User ID for your database (blank = use SSPI)
/password -     the password for your DB (blank = use SSPI)
/out -          the output directory for generated items. (default = current)
/lang -         generated code language: cs or vb (default = cs)
/provider -     the name of the provider to use
/includeTableList -    used for generating classes. A comma-delimited list that defines which tables should be used to generate classes
/config -       the path your App/Web.Config - used to instance SubSonic
/excludeTableList    the opposite of tablelist. These tables will NOT be used to generate classes

******** Arguments Matching SubSonic web.config Settings ********
Just add a '/' in front
/generatedNamespace -  the namespace to use for generated code
/templateDirectory -   the directory containing template overrides
/fixPluralClassNames - reset all plural table names to singular? true/false
/useSPs -              whether to generate SP wrapper (true/false)
/spClassName -         default is 'StoredProcedures' - this will override that
/stripTableText -      replace table text with this command
/stripColumnText -     replace column text with this command
/stripParamText -      replace SP param text with this command
/appendWith -          when you have reserved words in your table columns we need to append it with something. Our default is 'X'.You can change that here.
/spStartsWith -        use SPs that start with this
/viewStartsWith -      use Views that start with this
/relatedTableLoadPrefix - prefix related table loaders
/removeUnderscores -   whether to remove underscores from generated object names (true/false) default is false
/templateDirectory     The path to your custom templates. This is a directory reference
/regexMatchExpression
/regexReplaceExpression
/regexIgnoreCase
/regexDictionaryReplace
/generateLazyLoads
/generateRelatedTablesAsProperties
/extractClassNameFromSPName
/includeProcedureList
/excludeProcedureList

 

***************************************************************

下面是一個使用的例子:

cd C:\Program Files\SubSonic\SubSonic 2.0.1

sonic generate /server localhost /db SubSonicDemo /out C:\SubsonicDemo /config "C:\Program Files\SubSonic\SubSonic 2.0.1\sonic.exe.config"

sonic scriptschema /server localhost /db SubSonicDemo /out C:\SubsonicDemo /config "C:\Program Files\SubSonic\SubSonic 2.0.1\sonic.exe.config"

這個命令將產生一系列Model和Controller類,後面那行命令是產生指定資料庫SubSonicDemo 的schema。

下載產生的檔案及樣本工程

有個疑問:好像沒有產生分頁檔的命令,莫非只能用SubSonicCentral產生?知道的告知一聲

***************************************************************

下面是上面用到的sonic.exe.config檔案:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="dataConfiguration"
 type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
requirePermission="false"/>
    <section name="SubSonicService"
type="SubSonic.SubSonicSection, SubSonic"
allowDefinition="MachineToApplication"
restartOnExternalChanges="true"
requirePermission="false"/>
  </configSections>
  <appSettings/>
  <connectionStrings>
    <add name="SubsonicDemo"
connectionString="Data Source=localhost; Database=SubsonicDemo; Integrated Security=true;"/>

  </connectionStrings>
  <dataConfiguration defaultDatabase="SubsonicDemoConnection"/>
  <SubSonicService defaultProvider="SubsonicDemo" >
    <providers>
      <clear/>
     <add name="SubsonicDemo" type="SubSonic.SqlDataProvider, SubSonic"
connectionStringName="SubsonicDemo" generatedNamespace
      ="SubsonicDemo" />
    </providers>
  </SubSonicService>
</configuration>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.