nerdy

public static int LinqAddMovie(Movies Amovie)

{

int? r_value = 0; // you need the int? to say integer but could be null

MoviesDataContext db = new MoviesDataContext();

db.AddMovie(Amovie.Name, Amovie.Description, Amovie.DateAdded,

ref r_value);

var r = (int)r_value; // have to cast, as could be null, now zero if null

// var figures out what type you want 🙂

return r;

}

 

and the sql is…

 

ALTER PROCEDURE

dbo.AddMovie

@p_Title varchar(50),

@p_Description

varchar(50),

@p_DateAdded

datetime,

@r_value

INT OUTPUT

 

 

/*

(

@parameter1 int = 5,

@parameter2 datatype OUTPUT

)

*/

AS

/* SET NOCOUNT ON */

INSERT INTO

Movies(Title,Description,DateAdded)

VALUES

(@p_Title,@p_Description,@p_DateAdded)

SELECT

@r_value = Count(*) FROM MOVIES

RETURN

 

 

 

Let me an award a prize to a fab blog…

 

http://blogs.msdn.com/wriju/archive/2009/04/10/linq-to-sql-returning-scalar-value-from-stored-procedure.aspx

 

 

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s