SubSonic 3 简单查询工具 [英] SubSonic 3 Simple Query Tool

查看:27
本文介绍了SubSonic 3 简单查询工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 SubSonic 3(.0.0.2) 和文档页面中的简单查询工具 (http://subsonicproject.com/docs/Simple_Query_Tool) 暗示有一种方法可以轻松获取表列名称(例如 Product.ProductNameColumn):

I want to use the Simple Query tool in SubSonic 3(.0.0.2) and the docs page (http://subsonicproject.com/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 简单查询工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆