dimanche 28 juin 2015

How to get stored procedure return value using linq with C#?

have a stored Procedure that do some operation and return 1 or 0 as below.

CREATE PROCEDURE dbo.UserCheckUsername11
(
    @Username nvarchar(50)
)
AS
BEGIN
SET NOCOUNT ON;

IF Exists(SELECT UserID FROM User WHERE username =@Username) 
    return 1
ELSE
    return 0
END

Using linq I tried to get return value. But i am getting the output as -1 always.

Below is my Linq code :

 using (PlanGenEntities3 entity2 = new PlanGenEntities3())
 {                
    var result = entity2.Entity_test_GetHoliday();
    string output = result.ToString();
 }

How to solve this ?

Aucun commentaire:

Enregistrer un commentaire