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().OrderBy(e => e.Name))
{//fileManager.StartNewFile(entity.Name + "RepositoryExt.cs");//BeginNamespace(namespaceName, code);    
#>	public partial interface I<#=entity.Name#>Dal :IBaseDal<<#=entity.Name#>>{}
<#}#>}



本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部