既然要學習nhibernate,那知道如何執行儲存過程自然是必不可少的,網上有很多資料是用新建對映檔案的方式在nhibernate中執行儲存過程,我個人覺得這真的不太好,反覆琢磨後搞出了下面的這種方式,希望對大家有幫助。
create procedure [dbo].[proc_addsysdict]
@id uniqueidentifier,
@dictcode nvarchar(50),
@dictname nvarchar(50),
@parentcode uniqueidentifier
asbegin
set nocount on;
-- insert statements for procedure here
insert into sys_dict(id, dictcode, dictname, parentcode, remarks,createtime) values(@id,@dictcode,@dictname,@parentcode,'proc備註',getdate())
end
public actionresult index()
catch (exception ex)}}
#endregion
return view();
}
create procedure [dbo].[proc_addsysdict02]
@dictcode nvarchar(50),
@dictname nvarchar(50),
@parentcode uniqueidentifier
asbegin
set nocount on;
declare @id uniqueidentifier;
set @id = newid();
-- insert statements for procedure here
insert into sys_dict(id, dictcode, dictname, parentcode, remarks,createtime) values(@id,@dictcode,@dictname,@parentcode,'proc備註',getdate());
select @id
end
public actionresult index()
catch (exception ex)}}
#endregion
return view();
}
create procedure [dbo].[proc_removesysdict]
@dictname nvarchar(50),
@parentcode uniqueidentifier
asbegin
-- 若設定了set nocount on則無論刪除了多少行都返回-1
-- set nocount on;
-- insert statements for procedure here
delete from sys_dict where parentcode=@parentcode and dictname like '%'+@dictname+'%';
end
public actionresult index()
catch (exception ex)}}
#endregion
return view();
}
create procedure [dbo].[proc_updatesysdict]
-- add the parameters for the stored procedure here
@oldparentcode uniqueidentifier,
@newparentcode uniqueidentifier
asbegin
-- 若設定了set nocount on則無論刪除了多少行都返回-1
-- set nocount on;
-- insert statements for procedure here
update sys_dict set parentcode=@newparentcode where parentcode=@oldparentcode
end
public actionresult index()
catch (exception ex)}}
#endregion
return view();
}
create procedure [dbo].[proc_getsysdict]
@parentcode uniqueidentifier,
@dictname nvarchar(50)
asbegin
set nocount on;
-- insert statements for procedure here
select id, dictcode, dictname, parentcode, remarks, createtime from sys_dict where parentcode=@parentcode and dictname like '%'+@dictname+'%';
select @@rowcount as totalrowcount
end
public actionresult index()
catch (exception ex)}}
#endregion
return view();
}
NHibernate 執行儲存過程
前置條件 已經獲取了isession型別的物件 this.session 已經建立乙個儲存過程 proc name,該儲存過程有兩個引數 para1 varchar 型別,傳入引數 para2 number型別,傳出引數 int result 0 idbcommand cmd this.sessio...
Nhibernate執行帶輸出引數的儲存過程
可能會有業務邏輯問題而且會帶輸出 引數,可是nhibernate好像不支援out 配置 我沒找到不知道有沒有 換了個方法來執行 user id in integer,user name in varchar2,user pwd in varchar2,msg out varchar2 factory...
vc 中,ado執行sql server儲存過程
variant t recordsaffected string szsql string p ks adduser m szname m szpasswd trycatch com error e catch com error e 必須指定執行sql語句的commandtype是adcmdsto...