WYB
2021-03-22 91b8cdad021ab052e4991f3d41834a6f0ddc36b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension="/" #>
<#@ assembly name="System.Core.dll" #>
<#@ assembly name="System.Data.dll" #>
<#@ assembly name="System.Data.DataSetExtensions.dll" #>
<#@ assembly name="System.Xml.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Data" #>
<#@ import namespace="System.Data.SqlClient" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.IO" #>
<#@ include file="$(ProjectDir)DbHelper.ttinclude"  #>
<#@ include file="$(ProjectDir)ModelAuto.ttinclude"    #>
<# var manager = new Manager(Host, GenerationEnvironment, true); #>
<# 
    var OutputPath1 =Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Host.TemplateFile+"..")+"..")+"..");
    OutputPath1=Path.Combine(OutputPath1,"JiepeiWMS.Model","Models_New");
    if (!Directory.Exists(OutputPath1))
    {
        Directory.CreateDirectory(OutputPath1);
    }
#>
<# foreach (var item in DbHelper.GetDbTablesNew(config.ConnectionString, config.DbDatabase,config.TableName))
   {
         var tableName=item.ToString();
        manager.StartBlock(tableName+".cs",OutputPath1);//文件名
       #>
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace JiepeiWMS.Model.Models
{
     ///<summary>
     ///<#=tableName#>
     ///</summary>
     [Table("<#=tableName#>")]    
     public class <#=tableName#>
     {
     <# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){#>
 
         /// <summary>
        /// <#= column.Remark == "" ? column.ColumnName : column.Remark.Replace("\r\n"," ") #>
        /// </summary>
        <# 
         if(column.IsPrimaryKey) 
         {#>[Key]
        <#}#><# if(!column.IsNullable) {#>[Required]
        <# }#>public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
    <#
     }
     #> 
     }
}     
<#
   manager.EndBlock(); 
   }
  manager.Process(true);
   #>