Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a similar situation where I had to provide an interface between to purchased applications that were in production and being used by tons of different systems. This system had different table names throughout dev, test, and prod (ridiculous...) My solution was to leave a placeholder for the table number in the NHibernate config like so:</p> <pre><code>&lt;class name="MyClass" table="MyTable[tableNumber]"&gt; </code></pre> <p>And then implement INamingStrategy similar to:</p> <pre><code>public class MyCustomNamingStrategy : INamingStrategy { public string ClassToTableName(string className) { return DefaultNamingStrategy.Instance.ClassToTableName(className); } public string PropertyToColumnName(string propertyName) { return DefaultNamingStrategy.Instance.PropertyToColumnName(propertyName); } public string TableName(string tableName) { tableName = tableName.Replace("[tableNumber]", LocalSettings.TableNumber); return DefaultNamingStrategy.Instance.TableName(tableName); } public string ColumnName(string columnName) { return DefaultNamingStrategy.Instance.ColumnName(columnName); } public string PropertyToTableName(string className, string propertyName) { return DefaultNamingStrategy.Instance.PropertyToTableName(className, propertyName); } public string LogicalColumnName(string columnName, string propertyName) { return DefaultNamingStrategy.Instance.LogicalColumnName(columnName, propertyName); } } </code></pre> <p>And then set the naming strategy in the configuration:</p> <pre><code>myConfiguration.SetNamingStrategy(new MyCustomNamingStrategy()); </code></pre> <p>This way the table number could be stored in the App.config and the application could be moved across environments by only changing values in the App.config. I'm sure you could find a way to use this to change the table name to whatever date you needed...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload