How to get ISession in an ICommandInterpreter

Topics: Core
Jan 9, 2014 at 7:22 PM
I'm implementing SQLite support for Orchard. To do this, I've created SQLiteCommandInterpreter. SQLite is unique in that it has limited built-in alter table support. For example, it doesn't support removing or altering columns once created. There is a work around though but it requires querying the DB to get information on the characteristics of the original table.

In order to handle this, I need access to the NHibernate ISession (I think) so I can run a raw SQL query and get the result. The problem I have though is that when SQLiteCommandInterpreter is instantiated the session hasn't been initiated yet. How do I get access to the ISession object when I actually process the AlterTableCommand instead of when SQLiteCommandInterpreter is instantiated.
Developer
Jan 9, 2014 at 9:29 PM
You can access the session through ISessionLocator. I guess you implemented ICommandInterpreter. If indeed, then you should be able to inject ISessionLocator and access the session through it from your implementation.