- Create your sp in your db.
- Call it using the Session.CreateSQLQuery("exec myStoredProc")
- Create your sp
- map it.
- Call it.
First and foremost, remember always to use SELECT in your SP rather than RETURN.
Now, for the first case, this would look like this:
CREATE PROCEDURE [dbo].[GetIt]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
-- Insert statements for procedure here
SELECT 1342
END
This would be then called like this:
int query = session.CreateSQLQuery("exec GetIt").List
As for the second case, this would look like this:
ALTER PROCEDURE [dbo].[GetIt]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
-- Insert statements for procedure here
SELECT 1342 as Id, 'MyName' as Name
END
The mapping would then be:
exec GetIt
And finally, this would be executed like this:
IList
Beware that the return class referenced in the sql-query mapping should be mapped itself on its own, separately!