views:

503

answers:

2

Hi,

Hi have a stored proc that always returns a single row depending of a parameter:

IF @bleh = 1
  SELECT TOP 1 Xyz FROM Abc
ELSE
  SELECT TOP 1 Def FROM Abc

I must use SqlMetal to generate the DataContext but this stored procedure returns a IMultipleResults, which is an error. Instead it should return a ISingleResult...

If I remove the if (putting a single SELECT call), an ISingleResult return type is generated.

Any ideas?

+6  A: 
Ahmad Mageed
+1 well done! I didn't have VS 2008 installed, and I didn't want to 'muddy' my investigation by using VS 2010 Beta 2 just in case it was something that had been addressed (or not), glad you got to the bottom of it
RobS
@Rob thanks for following up :)
Ahmad Mageed
+1 + answered, wow thanks
Mike Gleason jr Couturier
@Mike great! Glad it was helpful.
Ahmad Mageed
A: 

These work arounds are interesting, but doesn't help for my situation.

sqlmetal wrongly generates code for my sproc as ISingleResult. I need multiple results! Check this out. SqlMetal actually generates ISingleResult for a sproc like this:

CREATE PROCEDURE GetDetailReportData AS BEGIN
select * from Log END

This is unbelievable. Does anyone ever use sprocs with sqlmetal? it appears to simply not work. Please help steer me in the direction of a work around if there is one.

Thanks, willgroove

willgroove