title: ServiceStack: Accessing the session in InsertFilter and UpdateFilter
body: <p>I have a C#.net application in which I'm writing to a sql server database.  The SQL Server tables all have common record management columns (DateCreated, DateLastUpdated, CreatedUserId etc...) and I wish to abstract the population of these fields into an InsertFilter and UpdateFilter.</p>
  <p>Here's a cut down version of the AppHost's Configure method..</p>
  <pre><code>public override void Configure(Container container)
  {
      ICacheClient CacheClient = new MemoryCacheClient();
      container.Register(CacheClient);
  
      var connectionString = ConfigurationManager.ConnectionStrings[&quot;mydb&quot;].ConnectionString;
  
      container.Register&lt;IDbConnectionFactory&gt;(c =&gt; new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));
  
      container.Register&lt;IUserAuthRepository&gt;(c =&gt; new OrmLiteAuthRepository(c.Resolve&lt;IDbConnectionFactory&gt;()));
      var authRepo = (OrmLiteAuthRepository)container.Resolve&lt;IUserAuthRepository&gt;();
  
  
      OrmLiteConfig.InsertFilter = (dbCmd, row) =&gt;
      {
          var userSession = SessionFeature.GetOrCreateSession&lt;AuthUserSession&gt;(CacheClient);
          var recordManagementRow = row as IRecordManagement;
          if (recordManagementRow != null)
          {
              recordManagementRow.DateCreated = recordManagementRow.DateLastUpdated = DateTime.UtcNow;
              if (userSession != null)
                  recordManagementRow.CreatedUserId = recordManagementRow.LastUpdatedUserId = userSession.Id.ToInt();
          }
      };
  }
  </code></pre>
  <p>When executing I get the following exception on the first line of the OrmLiteConfig.InsertFilter delegate.  Does anyone have any better ideas for how I can retrieve the current user session id for insertion into the db?</p>
  <blockquote>
  <p>An exception of type 'System.NotImplementedException' occurred in ServiceStack.dll but was not handled in user code</p>
  <p>Additional information: This AppHost does not support accessing the current Request via a Singleton</p>
  </blockquote>