zoukankan      html  css  js  c++  java
  • vs2015添加T4模版

    <#@ template language="C#" debug="false" hostspecific="true"#>
    <#@ include file="EF6.Utility.CS.ttinclude"#><#@ 
    output extension=".cs"#><#
    
    // 声明明edmx文件的位置变量
    const string inputFile = @"../Simple.Domain/Model.edmx";
    var textTransform = DynamicTextTransformation.Create(this);
    var code = new CodeGenerationTools(this);
    var ef = new MetadataTools(this);
    var typeMapper = new TypeMapper();
    var    fileManager = EntityFrameworkTemplateFileManager.Create(this);
    var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
    
    #>//------------------------------------------------------------------------------
    // 请不要手动修改此文件中的代码
    //------------------------------------------------------------------------------
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Simple.Domain;//引用Domain的命名空间
    
    namespace Simple.IDAO
    {
    
    <#
    foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
    {
    // 不需要新建文件
    //fileManager.StartNewFile(entity.Name + ".cs");
    
    #>    public interface I<#=entity.Name#>Dao:IBaseDao<<#=entity.Name#>> //生成实体对象接口
        {
        }
    
    <#   
    }
    #>
    
    }
    //end namespace
    <#+
    // 这个类必不可少
    public class TypeMapper
    { 
    
    // 这个方法必须有用
    public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
    {
    return itemCollection
    .OfType<T>()
    .Where(i => true)
    .OrderBy(i => i.Name);
    }
    
    }
    
    public static void ArgumentNotNull<T>(T arg, string name) where T : class
    {
    if (arg == null)
    {
    throw new ArgumentNullException(name);
    }
    }
    #>
  • 相关阅读:
    python_基础
    大话数据结构笔记
    c语言深度剖析
    liunx 第一章
    zookeper实现分布式锁
    zookeeper图形化操作工具
    windows下zookeeper集群的搭建
    TransactionInterceptor]: Bean property 'transactionManagerBeanName' is not w
    深入浅出zookeeper(二)
    com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of
  • 原文地址:https://www.cnblogs.com/no27/p/7160604.html
Copyright © 2011-2022 走看看