The Darkside

Shedding light on things and stuff

 
  Home :: Contact :: Syndication  :: Login
  75 Posts :: 0 Stories :: 49 Comments :: 2 Trackbacks

Ads

Archives

Post Categories

Open Source Projects

Other Blogs

Although Castle ActiveRecord handles the majority, if not all, of your data persistence requirements, there is often a need to get access to the underlying database connection for tasks like bulk SQL copies, one-off stored procedure calls, etc.

This  snippet of code demonstrates getting the connection and calling a stored procedure:

using (ISession session = ActiveRecordMediator.GetSessionFactoryHolder().CreateSession(typeof(ActiveRecordBase)))
{
    using (IDbCommand command = session.Connection.CreateCommand())
    {
        command.CommandText = "up_DoStuff"
        command.CommandType = CommandType.StoredProcedure;
        command.CommandTimeout = 300;   
        command.ExecuteNonQuery();
        command.Connection.Close();
    }
    session.Close();
}

That's it.

posted on Monday, March 03, 2008 3:03 PM
Comments have been closed on this topic.