在配置中,有一种方法可以设置要排除的表,但我需要的是设置要包括的表的名称,排除其他所有内容。
有没有人已经这么做了?
干杯!亚历克斯
发布于 2009-08-04 11:45:26
好了,我已经做到了..。
在tt文件的几个地方添加了下面这行: if(!ExcludeTables.Contains(tbl.Name)) {if((IncludeTables.Length != 0 &&!IncludeTables.Contains(tbl.Name);
如果(!ExcludeTables.Contains(fk.OtherTable)){ if((IncludeTables.Length != 0 &&!IncludeTables.Contains(fk.OtherTable)继续,则在ActiveRecord.tt下的关系上继续(!ExcludeTables.Contains(fk.OtherTable)){if((IncludeTables.Length!=0&&!IncludeTables.Contains(fk.OtherTable)
在settings.ttinclude string[] IncludeTables = string[]{ "tableA","tableB“}上添加了以下内容;
这很容易实现,但是将来的SubSonic更新将会删除我的自定义设置。可以将其添加到项目中吗?
谢谢!亚历克斯
发布于 2009-08-18 02:01:22
还有另一个“黑客”,你只需要更改Settings.ttinclude;只需替换string[] ExcludeTables……通过以下方式:
public interface ITableExcluder
{
bool Contains(string table);
bool ShouldExclude(string table);
bool ShouldInclude(string table);
}
/// <summary>
/// Custom class to exclude tables via a programmatic means.
/// </summary>
public class TableExcluder : ITableExcluder
{
public bool Contains(string tableName)
{
if (ShouldExclude(tableName))
return true;
return !ShouldInclude(tableName);
}
public bool ShouldExclude(string tableName)
{
switch (tableName)
{
case "sysdiagrams":
case "BuildVersion":
return true;
}
if (tableName.StartsWith("blog_"))
return true;
return false;
}
public bool ShouldInclude(string tableName)
{
return true;
}
}
//This replaces the string array
ITableExcluder ExcludeTables = new TableExcluder();有点麻烦,但至少它避免了替换其他文件的一部分!
https://stackoverflow.com/questions/1226338
复制相似问题