0

Can we call a STOREDPROC which inserts data into db which has no return value from NHIBERNATE? If so can any one please help me out with a small sample.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
user669803
  • 11
  • 1
  • 4

3 Answers3

0

I don't know if it works if you define the query in XML, but you can simply create an ISQLQuery and call ExecuteUpdate() on it.

cremor
  • 6,669
  • 1
  • 29
  • 72
0

Use ADO.NET, -Get Connection object from NHibernate session, -Create a Dbcommand -Set your procedure in Dbcommand text -Run the command

Note: NHibernate might supprot stored procs but its a complicated process refer to this link, so opt ADO.NET which is optimum in your scenario.

sqlnewbie
  • 857
  • 3
  • 16
  • 39
0

This is one way:-

In your mappings file:-

<sql-query name="UpdateMeetingsSentFromTeamLeader">
  <![CDATA[exec uspUpdateMeetingsSentFromTeamLeader :MeetingId]]>
</sql-query>

and your code is:-

public void UpdateMeetingsSentFromTeamLeader(int meetingId)
{
    Session
    .GetNamedQuery("UpdateMeetingsSentFromTeamLeader")
    .SetInt32("MeetingId", meetingId)
    .ExecuteUpdate();
}
Rippo
  • 22,117
  • 14
  • 78
  • 117