zoukankan      html  css  js  c++  java
  • T4模板

    创建模板,建议从最外层->最内层写,不然很乱

    <#@ template language="C#" debug="false" hostspecific="true"#>
    <#@ include file="EF.Utility.CS.ttinclude"#>
    <#@ output extension=".cs"#>
     
    <#
    
    CodeGenerationTools code = new CodeGenerationTools(this);
    MetadataLoader loader = new MetadataLoader(this);
    CodeRegion region = new CodeRegion(this, 1);
    MetadataTools ef = new MetadataTools(this);
    
    string inputFile = @"..\项目名称\Model1.edmx";
    
    EdmItemCollection ItemCollection = loader.CreateEdmItemCollection(inputFile);
    string namespaceName = code.VsNamespaceSuggestion();
    
    EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);
    
    #>
    //复制自己手动写的类的命名空间替换下面的命名空间
    using CZBK.ItcastOA.IDAL;
    using CZBK.ItcastOA.Model;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace CZBK.ItcastOA.DAL
    {
    <#
    // Emit Entity Types
    
    foreach (EntityType entity in ItemCollection.GetItems<EntityType>().OrderBy(e => e.Name))
    {
        //fileManager.StartNewFile(entity.Name + "RepositoryExt.cs");
        //BeginNamespace(namespaceName, code);    
    #>		
    	public partial class <#=entity.Name#>Dal :BaseDal<<#=entity.Name#>>,I<#=entity.Name#>Dal
        {
    
        }
    <#}#>
    	
    }
    

      

  • 相关阅读:
    network issue troubleshooting
    xpath tutorial
    自己的Queue
    TCP/IP Socket
    C++对话框创建及修改对话框属性
    C++文件和目录的创建和删除
    C#程序中降低内存清理方法
    UDP通信
    C++ 中TCHAR字符串数组转化为Char类型数组
    配置supervisor 让laraver的队列实现守护进程
  • 原文地址:https://www.cnblogs.com/BOSET/p/7017656.html
Copyright © 2011-2022 走看看