Soft model template generates nullable type fields

Source: Internet
Author: User

Dynamic soft code Generation nullable type

<#@ Template language="C #"Hostspecific="True"#><#@ Output extension=". CS"#><# Tablehost Host=(Tablehost) (Host); Host. Fieldlist.sort (Codecommon.comparebyintorder);>usingSystem;usingSystem.Text;usingSystem.Collections.Generic;usingSystem.Data;namespace<#= host. NameSpace #>. model<#if(host. Folder.length >0) {#>.<#= host. Folder #><#} #>{    <#if(host. Tabledescription.length >0) {#>//<#= host. Tabledescription #><#} #> Public class<#= host. Getmodelclass (host. TableName) #>    {                          <#foreach(Columninfo Cinchhost. FieldList) {#>/// <summary>        /// <#= String. IsNullOrEmpty (c.description)? C.columnname:c.description #>        /// </summary>                Private<#= Gettypename (c) #> _<#= c.columnname.tostring (). ToLower () #>;  Public<#= Gettypename (c) #> <#= c.columnname #>        {            Get{return_<#= c.columnname.tostring (). ToLower () #>; } Set{_<#= c.columnname.tostring (). ToLower () #> =value;} }                <#} #>                       }}<#+Private stringGettypename (columninfo c) {if(C.nullable && (Codecommon.dbtypetocs (c.typename). ToString (). ToLower ())! ="string")//If the field can be empty, and not a string type is converted to a nullable type                {                   returnCodecommon.dbtypetocs (C.typename) +"?"; }                                Else                {                     returnCodecommon.dbtypetocs (c.typename); }                            }                #>

The field of the value type in 1.Model is changed to a nullable type. Specific settings: Tools-Options-Code Parameters-field type mapping [Isvaluetype] segment;
If you don't, you can delete the corresponding fields in the configuration file.
2. Batch code generation, table name unified go to prefix function
3. Code generator Add code Save function
4. Added efficient connection mode: Enable this for fast connection in case of a large number of tables.
5. Added support for MySQL database.
6. Query Analyzer Right-click Add-on function: Generate SQL script splicing code directly from SQL statement, which provides more flexible data layer code generation.
7. Query Analyzer Right-click additional functionality: Generate Data scripts based on SQL query results instead of data scripts for the entire table.
8. Based on the SQL Method dal code generation, add method to increase the value of the field null insertion judgment
9. BLL Add public list<> getmodellist () method to return list<> data.
10. Record error log information.
11. Publish the BLL Layer Code template component source.
12. Publish the Web layer code generation component source.
13. Release model code generation component source

Soft model template generates nullable type fields

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.