Gibt es trotzdem ein Präfix zu Tabellennamen zur Konfigurationszeit mit Castle Active Record hinzufügen?Tabellenpräfix mit Castle Active Record
[ActiveRecord("Address")]
public class Address : ActiveRecord<Address> {}
würde ich die aktuelle Tabelle wie erstellt/verknüpften „PRODAddress“ oder „DEBUGAddress“ zu sein. Gibt es etwas eingebautes, das ich nicht sehe?
Danke,
[EDIT] Ich habe die allgemeine Antwort unten markiert, aber hier ist der eigentliche Code Tabellenpräfixe für Castle Active Record zu implementieren:
...
ActiveRecordStarter.ModelsCreated += ActiveRecordStarter_ModelsCreated;
ActiveRecordStarter.Initialize(source, typeof(Address));
...
private static void ActiveRecordStarter_ModelsCreated(ActiveRecordModelCollection models, IConfigurationSource source)
{
string tablePrefix = ConfigurationManager.AppSettings["TABLE_PREFIX"];
if (String.IsNullOrEmpty(tablePrefix)) return;
foreach (ActiveRecordModel model in models)
{
model.ActiveRecordAtt.Table = String.Format("{0}{1}", tablePrefix, model.ActiveRecordAtt.Table);
}
}
auf die Verwendung hinzugefügt ActiveRecord FAQ: http://using.castleproject.org/display/AR/FAQ –
Sehr cool. Danke. – ConsultUtah