使用T4模板同时生成多个类文件
2024-08-30 08:57:51
代码:
<#@ 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,);
MetadataTools ef = new MetadataTools(this); string inputFile = @"..\\OA.Model\\DataModel.edmx"; EdmItemCollection ItemCollection = loader.CreateEdmItemCollection(inputFile);
string namespaceName=code.VsNamespaceSuggestion(); EntityFrameworkTemplateFileManager fileManager=EntityFrameworkTemplateFileManager.Create(this);
#>
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码已从模板生成。
//
// 手动更改此文件可能导致应用程序出现意外的行为。
// 如果重新生成代码,将覆盖对此文件的手动更改。
// </auto-generated>
//------------------------------------------------------------------------------
<#
foreach(EntityType entity in ItemCollection.GetItems<EntityType>().OrderBy(e=>e.Name))
{
fileManager.StartNewFile("I"+entity.Name+"Dal" + ".cs");
#> using OA.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace OA.IDAL
{
public partial interface I<#=entity.Name#>Dal : IBaseDal<<#=entity.Name#>>
{ }
} <#}#>
<# fileManager.Process();
#>
最新文章
- Maven远程仓库的配置
- Npoi导出Excel 实战篇(Webform)
- python类型转换
- Android笔记:DrawerLayout抽屉布局的使用
- MVC用户登录方法(lamda表达式)
- linux php安装扩展方法 查找配置文件
- 关于json对象的遍历
- 如何判断浏览器为ie10以上
- 如何在MicroPython TPYBoard 添加自定义类库
- linux TCP头部的构造的简单分析
- Spring对象生存周期(Scope)的分析
- .NET Core 跨平台发布Linux和OSX
- 《CLR Via C#》读书笔记:24.运行时序列化
- June 5. 2018 Week 23rd Tuesday
- Java 对远程文件的操作
- Learning-Python【31】:操作系统基础知识
- Pycharm2018的激活方法或破解方法(必须加host)
- 【Git】简单使用
- Visual Studio: 一键卸载所有组件工具,彻底卸载干净。
- css固定footer到浏览器底部的方法