我想使用 SubSonic 3(.0.0.2) 和文档页面中的简单查询工具 (subsonicproject/docs/Simple_Query_Tool) 暗示有一种方法可以轻松获取表列名称(例如 Product.ProductNameColumn):
I want to use the Simple Query tool in SubSonic 3(.0.0.2) and the docs page (subsonicproject/docs/Simple_Query_Tool) implies there's a way to easily get hold of table column names (e.g. Product.ProductNameColumn):
int records = new Select(Product.ProductIDColumn, Product.ProductNameColumn). From<Product>().GetRecordCount();ActiveRecord 生成的类似乎没有公开此信息 - 没有 ProductIDColumn 属性.这是第 2 版的挂断吗?
The ActiveRecord generated class doesn't appear to expose this info - there is no ProductIDColumn property. Is this a hang-up from version 2?
推荐答案目前无法在 SubSonic 3 中获取列名称.您仍然可以使用带有字符串的简单查询工具,或者如果您修改 Structs.tt 模板,您可以为您生成它们.找到这段代码(我认为是第 45 行):
There's no way to get the column names in SubSonic 3 at the moment. You can still use the simple query tool with strings or if you modify the Structs.tt template you can get them generated for you. Find this section of code (I think it's line 45):
<# foreach(var col in tbl.Columns){ #> public IColumn <#=col.CleanName#>{ get{ return this.GetColumn("<#=col.Name#>"); } } <# }#>并修改它,使其看起来像这样:
and modify it so it looks like this:
<# foreach(var col in tbl.Columns){ #> public IColumn <#=col.CleanName#>{ get{ return this.GetColumn("<#=col.Name#>"); } } public static string <#= col.CleanName #>Column{ get{ return "<#= col.Name #>"; } } <# }#>然后您应该将所有列名称自动生成为静态属性.
Then you should get all your column names automatically generated as static properties.
更多推荐
SubSonic 3 简单查询工具
发布评论