views:

109

answers:

1

I have a really simple stored procedure that looks like this:

CREATE PROCEDURE _Visitor_GetVisitorIDByVisitorGUID
(
 @VisitorGUID AS UNIQUEIDENTIFIER
)

AS

DECLARE @VisitorID AS bigint

SELECT @VisitorID = VisitorID FROM dbo.Visitor WHERE VisitorGUID = @VisitorGUID

--Here's what I've tried 
RETURN @VisitorID 'Returns an IDataReader
SELECT @VisitorID 'Returns an IDataReader
--I've also set it up with a single output
--parameter, but that means I need to pass
--the long in by ref and that's hideous to me

I'm trying to get nettiers to generate a method with this signature:

public long VisitorService.GetVisitorIDByVisitorGUID(GUID visitorGUID);

Basically I want Nettiers to call ExecuteScalar instead of ExecuteReader. What am I doing wrong?

+1  A: 

Why not use the custom data access functionality to call your stored proc with ExecuteScalar? (http://nettiers.com/DataLayer.ashx#Read_Methods:_4)

var vistorId = (long)DataRepository.Provider.ExecuteScalar(CommandType.StoredProcedure, "_Visitor_GetVisitorIDByVisitorGUID");

The body of the stored proc should look like:

Select VisitorID 
FROM dbo.Visitor 
WHERE VisitorGUID = @VisitorGUID

Return

or

Declare @VisitorId bigint
Set @VisitorId = (
                Select VisitorId
                From dbo.Visitor
                Where VisitorGuid = @VisitorGUID
                )

Select @VisitorId

Return
Thomas
That helps, but I still think I should be able to use the the service layer (we have caching setup) without having to create a custom method.
Micah
@Micah - Given the way the docs read, I'm guessing that anytime you go off the reservation of wanting something other than an entire instance (i.e. a whole row), you have to roll your own.
Thomas