如何使用Castle ActiveRecord执行存储过程?

c.s*_*kun 8 .net c# stored-procedures castle-activerecord

我相信在网上的某个地方有关于这个话题的讨论,但我丢失了网址,我无法通过谷歌搜索找到它.

我现在可能会尝试的是:

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);
}
Run Code Online (Sandbox Code Playgroud)

但是,我不太确定这是否是正确的方法,或者是否存在更好的方法.

小智 1

我在 ActiveRecord 代码中实现存储过程时使用的博客是 Rodj 的这篇文章 ( http://blog.rodj.org/archive/2008/05/23/activerecord-nhibernate-and-sql-stored-procedures.aspx ) 。利用他的帖子和评论,我能够让它发挥作用。我还没有决定这是否是最好的方法。