68 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
| <#@ template debug="false" hostspecific="true" language="C#" #>
 | |
| <#@ output extension=".cs" #>
 | |
| <#@ 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(Host.TemplateFile+"..");
 | |
| 	OutputPath1=Path.Combine(OutputPath1,"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);//文件名
 | |
| #>
 | |
| 
 | |
| //--------------------------------------------------------------------
 | |
| //     此代码由T4模板自动生成  byzhouhang 20210918
 | |
| //	   生成时间 <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#> 
 | |
| //     对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
 | |
| using System;
 | |
| using IRaCIS.Core.Domain.Share;
 | |
| using System.ComponentModel.DataAnnotations;
 | |
| using System.ComponentModel.DataAnnotations.Schema;
 | |
| namespace IRaCIS.Core.Domain.Models
 | |
| {
 | |
| 	 ///<summary>
 | |
| 	 ///<#=tableName#>
 | |
| 	 ///</summary>
 | |
| 	 [Table("<#=tableName#>")]	
 | |
| 	 public class <#=tableName#> : Entity, IAuditUpdate, IAuditAdd
 | |
| 	 {
 | |
| 	 <# 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; }
 | |
| 	<#}#> 
 | |
| 	 }
 | |
| 
 | |
| 	   public virtual DbSet<<#=tableName#>> <#=tableName#> { get; set; }
 | |
| }	 
 | |
| <#
 | |
|    manager.EndBlock(); 
 | |
|    }
 | |
|   manager.Process(true);
 | |
|    #> |