SubSonic 3 简单查询工具

编程入门 行业动态 更新时间:2024-10-27 02:18:41
本文介绍了SubSonic 3 简单查询工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用 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 简单查询工具

本文发布于:2023-11-06 16:05:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564158.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:简单   工具   SubSonic

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!