在 PetaPoco 中将 [ResultColumn] 添加到 Database.tt
Adding [ResultColumn] to Database.tt in PetaPoco
我是 PetaPoco 的狂热用户。有什么方法可以调整 Database.tt(用于生成 POCO)以在特定 table 中指定 ResultColumn?
TIA
目前,Database.tt 状态:
// Tweak Schema
tables["tablename"].Ignore = true; // To ignore a table
tables["tablename"].ClassName = "newname"; // To change the class name of a table
tables["tablename"]["columnname"].Ignore = true; // To ignore a column
tables["tablename"]["columnname"].PropertyName="newname"; // To change the property name of a column
tables["tablename"]["columnname"].PropertyType="bool"; // To change the property type of a column
除了这些说明(效果很好)之外,我不知道如何更改模板。我希望有一个类似的声明可以产生如下的 POCO:
[TableName("phoenix.view_medical_records")]
[ExplicitColumns]
public partial class view_medical_records
{
[Column] public string lastname { get; set; }
[Column] public string firstname { get; set; }
[Column] public string birthdate { get; set; }
[Column] public int? chart_number { get; set; }
[ResultColumn] public DateTime tservice { get; set; }
[Column] public string status { get; set; }
[ResultColumn] public DateTime tcompleted { get; set; }
[Column] public string procedure_description { get; set; }
[Column] public string description { get; set; }
[Column] public string provider { get; set; }
}
注意:自动提供 [ResultColumn] 属性?!
谢谢。
根据我对问题的评论,PetaPoco 不支持通过 T4 生成器文件的结果列。但是,解决方法是忽略列
tables["phoenix.view_medical_records"]["tservice"].Ignore = true;
tables["phoenix.view_medical_records"]["tcompleted"].Ignore = true;
并且,为生成的提供列的部分提供部分 类。
public partial Poco1
{
// Generated by PP
}
public partial Poco1
{
// Supplied by the developer (Must be in same namespace)
[ResultColumn] public DateTime tservice { get; set; }
[ResultColumn] public DateTime tcompleted { get; set; }
}
我是 PetaPoco 的狂热用户。有什么方法可以调整 Database.tt(用于生成 POCO)以在特定 table 中指定 ResultColumn?
TIA
目前,Database.tt 状态:
// Tweak Schema
tables["tablename"].Ignore = true; // To ignore a table
tables["tablename"].ClassName = "newname"; // To change the class name of a table
tables["tablename"]["columnname"].Ignore = true; // To ignore a column
tables["tablename"]["columnname"].PropertyName="newname"; // To change the property name of a column
tables["tablename"]["columnname"].PropertyType="bool"; // To change the property type of a column
除了这些说明(效果很好)之外,我不知道如何更改模板。我希望有一个类似的声明可以产生如下的 POCO:
[TableName("phoenix.view_medical_records")]
[ExplicitColumns]
public partial class view_medical_records
{
[Column] public string lastname { get; set; }
[Column] public string firstname { get; set; }
[Column] public string birthdate { get; set; }
[Column] public int? chart_number { get; set; }
[ResultColumn] public DateTime tservice { get; set; }
[Column] public string status { get; set; }
[ResultColumn] public DateTime tcompleted { get; set; }
[Column] public string procedure_description { get; set; }
[Column] public string description { get; set; }
[Column] public string provider { get; set; }
}
注意:自动提供 [ResultColumn] 属性?!
谢谢。
根据我对问题的评论,PetaPoco 不支持通过 T4 生成器文件的结果列。但是,解决方法是忽略列
tables["phoenix.view_medical_records"]["tservice"].Ignore = true;
tables["phoenix.view_medical_records"]["tcompleted"].Ignore = true;
并且,为生成的提供列的部分提供部分 类。
public partial Poco1
{
// Generated by PP
}
public partial Poco1
{
// Supplied by the developer (Must be in same namespace)
[ResultColumn] public DateTime tservice { get; set; }
[ResultColumn] public DateTime tcompleted { get; set; }
}