views:

1325

answers:

2

I believe there is a discussion on this very topic somewhere on the net but I lost the url and I am unable to find it via googling.

What I might try right now would be:

ISessionFactoryHolder factoryHolder = ActiveRecordMediator<EntityClass>.GetSessionFactoryHolder();
ISession session = factoryHolder.CreateSession(typeof(EntityClass));
try
{
    IDbCommand cmd = session.Connection.CreateCommand();
    cmd.CommandText = "spName";
    cmd.ExecuteNonQuery();
}
catch(Exception ex)
{

}
finally
{
    factoryHolder.ReleaseSession(session);
}

However, I am not quite sure if this is the correct way to do this or if perhaps a better way exists.

+1  A: 

The blog I used when implementing stored procedures in my ActiveRecord code was this post by Rodj (http://blog.rodj.org/archive/2008/05/23/activerecord-nhibernate-and-sql-stored-procedures.aspx). Using his post and the comments I was able to get this to work. I haven't decided if this is the best way yet.

okcodemonkey
that link is broken...
Mitch Wheat
+1  A: 

You can also get an IDbConnection with:

ActiveRecordMediator.GetSessionFactoryHolder()
    .GetSessionFactory(typeof(ActiveRecordBase))
    .ConnectionProvider.GetConnection();
Mauricio Scheffer
Check out the ActiveRecord FAQ: http://using.castleproject.org/display/AR/FAQ
Mauricio Scheffer
This doesn't seem to work, it says that ConnectionProvider doesn't exist.
Justin