How do I call a stored procedure from NHibernate that has no result?

后端 未结 7 1496
慢半拍i
慢半拍i 2020-12-09 08:02

I have a stored procedure that logs some data, how can I call this with NHibernate?

So far I have:

ISession session = ....
IQuery query = session.Cre         


        
相关标签:
7条回答
  • 2020-12-09 08:52

    You can use UniqueResult to execute a stored proc that doesn't return anything. I'm using the following to call a stored proc that either inserts or updates a record to track users currently logged in to our ASP.NET MVC site.

    IQuery query = session.GetNamedQuery("UserSession_Save");
    query.SetInt32("UserID", userID);
    query.SetString("CookieID", cookieID);
    query.SetString("Controller", controller);
    query.SetString("Action", action);
    
    query.UniqueResult();
    
    0 讨论(0)
提交回复
热议问题