SubSonic 命令行参数及使用示例

以下是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 >

你可能感兴趣的:(BSON)