calling stored procedure with linq

后端 未结 1 1386
天涯浪人
天涯浪人 2021-01-27 16:50

I am new to Linq server. I have a stored procedure in my databse that retuens count number.

select COUNT(*) from tbl_WorkerUsers 
        where WorkerCode=@Wcode         


        
相关标签:
1条回答
  • 2021-01-27 17:00

    Define your Stored Procedure like this:

    CREATE PROCEDURE [dbo].[checkWorkerCodeAvailibility] 
        @Wcode int = 0
    AS
    BEGIN
        SET NOCOUNT ON;
    
        DECLARE @Result INT
        SELECT @Result = COUNT(*) FROM tbl_WorkerUsers WHERE WorkerCode=@Wcode
        RETURN @Result
    END
    

    You can then access this using the following code:

    int result = db.checkWorkerCodeAvailibility(Int32.Parse(WCode));
    
    0 讨论(0)
提交回复
热议问题