admin 管理员组文章数量: 1087649
ASP T4模板批量生成代码
Dal.tt:(保存就会执行,生成代码)
<#@ 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 = @"..\\MyWeb.Model\\Model1.edmx";EdmItemCollection ItemCollection = loader.CreateEdmItemCollection(inputFile);
string namespaceName = code.VsNamespaceSuggestion();EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);#>
using MyWeb.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace MyWeb.IDAL
{<#
// Emit Entity Typesforeach (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#>>{}
<#}#>}
本文标签: ASP T4模板批量生成代码
版权声明:本文标题:ASP T4模板批量生成代码 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1700300424a386618.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论