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

    T4 模板自动生成带注释的实体类文件 - 只需要一个 SqlSugar.dll

    生成接口、类需要指定为局部partial,个性功能在自定义接口、类完成。

    <#@ 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 = @"..\CZBK.ItcastOA.Model\Model1.edmx";
    
    EdmItemCollection ItemCollection = loader.CreateEdmItemCollection(inputFile);
    string namespaceName = code.VsNamespaceSuggestion();
    
    EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);
    
    #>
    using CZBK.ItcastOA.Model;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace CZBK.ItcastOA.IDAL
    {
       
    <#
    // 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 interface I<#=entity.Name#>Dal :IBaseDal<<#=entity.Name#>>
        {
          
        }
    <#}#>
        
    }
  • 相关阅读:
    nginx安装:linux环境下安装包安装
    Effective C++
    Win32 Msg
    C++ 17
    Win32 Threads
    Exceptional C++
    C++11
    STL 分类
    C++类型转换
    红黑树
  • 原文地址:https://www.cnblogs.com/ecollab/p/6159877.html
Copyright © 2011-2022 走看看