1
A
回答
1
好吧,我已經做到了......
只是添加以下行的TT文件的幾個地方: 如果 (ExcludeTables.Contains(tbl.Name)!) {if((IncludeTables.Length!= 0 & &!IncludeTables.Contains(tbl.Name)))continue;
上ActiveRecord.tt 下關係略微不同的行,如果(!ExcludeTables.Contains(fk.OtherTable)){ 如果((IncludeTables.Length!= 0 & &!IncludeTables.Contains(FK .OtherTable)))繼續;
和加在settings.ttinclude以下 串[] IncludeTables =新的字符串[] { 「表A」, 「tableB的」};
這很容易實現,但未來的SubSonic更新將抹去我的定製。 這可以添加到項目中嗎?
謝謝! 亞歷克斯
1
還有另一個「黑客」,你只需要改變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();
一個黑客一點,但至少它避免了其他文件的更換零件!
看起來不錯!我會嘗試的! 實際上,我的實現要求更改所有文件上的代碼,這些問題將成爲SubSonic更新的問題。 – AlexCode 2009-08-19 08:57:30