【问题标题】:Modify .tt File c# for generate inheritance修改 .tt 文件 c# 以生成继承
【发布时间】:2020-06-19 10:55:10
【问题描述】:

有没有办法修改.tt(t4 模板)文件,以便在生成类时,它们会有继承?

我已经尝试了下面的 sn-p 但没有运气。

<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#> : EntityBase

【问题讨论】:

  • 你能再澄清一点吗?您是否希望从 EntityBase 继承?
  • 是的,来自 EntityBase

标签: c# .net frameworks entity t4


【解决方案1】:

我解决了,我必须在EntityClassOpening中添加继承

public string EntityClassOpening(EntityType entity)
{
     return string.Fromat(
      ...
      "{0} {1} partial class {2}{3} : EntityBase"
      ...
      )
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-25
    • 2011-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多