需要向实体框架自跟踪实体模板添加最大长度
我需要为我的自我跟踪实体添加最大长度 我已经尝试过 this
但它是使用 EntityObject Generator 而不是 Serf- 完成的跟踪实体生成器的
模板非常不同,我尝试剪切和粘贴代码,但总是收到错误消息:
语句不能出现在第一类功能之后 模板。仅样板、表达式和其他类功能 允许在第一类功能块之后。
我需要在哪里添加代码?
private bool IsNullable(TypeUsage usage)
{
return (bool)usage.Facets.First(facet => facet.Name == "Nullable").Value;
}
private bool HasMaxLength(TypeUsage usage)
{
return usage.Facets.Any(facet => facet.Name == "MaxLength");
}
private int MaxLength(TypeUsage usage)
{
return (int)usage.Facets.First(facet => facet.Name == "MaxLength").Value;
}
谢谢
I need to add max length to my self tracking entities
I have tried this
but it's done using the EntityObject Generator and not the Serf-Tracking Entity Generator
the template is very different, I have tried to cut and paste the code, but I always get the error message :
A Statement cannot appear after the first class feature in the
template. Only boilerplate, expressions and other class features are
allowed after the first class feature block.
where do I need to add the code ?
private bool IsNullable(TypeUsage usage)
{
return (bool)usage.Facets.First(facet => facet.Name == "Nullable").Value;
}
private bool HasMaxLength(TypeUsage usage)
{
return usage.Facets.Any(facet => facet.Name == "MaxLength");
}
private int MaxLength(TypeUsage usage)
{
return (int)usage.Facets.First(facet => facet.Name == "MaxLength").Value;
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将该代码放在模板的末尾并将其关闭到
<#+ #>
块中。定义可重用方法的示例位于文章开头的T4 模板能为我做什么?Put that code at the end of the template and close it into
<#+ #>
block. The example for defining reusable methods is at the beginning of the article under What can T4 templates do for me?