我是PetaPoco的狂热用户。有什么方法可以调整Database.tt(用于生成POCO)以在特定表中指定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]属性是否自动提供?!
谢谢。
答案 0 :(得分:1)
根据我对这个问题的评论,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; }
}