NHibernate使用带参数的存储过程删除

时间:2011-02-06 23:57:51

标签: nhibernate

这有多难?文档对此无用。

我想在sql server中使用带参数的存储过程删除,但每次都会出错。

ALTER PROCEDURE [dbo].[usp_DeleteFeed] 
@DateFrom datetime
AS
BEGIN
SET NOCOUNT ON;

DELETE FROM dbo.tblFeed WHERE  DateUpdated < @DateFrom

SET NOCOUNT OFF
END



<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <sql-query name="dbo.usp_DeleteFeed">
     exec dbo.usp_DeleteFeed @DateFrom=:DateFrom
 </sql-query>
</hibernate-mapping>

_feedRepository.Session.GetNamedQuery("dbo.usp_DeleteFeed").SetParameter("DateFrom", dateFrom).ExecuteUpdate();

0 个答案:

没有答案