简体   繁体   中英

How can I make a Stored procedure return a bit value?

I have a stored procedure similar to this:

CREATE PROCEDURE [dbo].[sp_mark_question]
AS
BEGIN
   SELECT  1 AS Authenticated,
           0 AS RC
END

It is executed like this:

var rc = await db.Database.SqlQuery<AnswerToClient>(sql).FirstOrDefaultAsync();

public class AnswerToClient
{
    public bool Authenticated { get; set; }
    public bool RC { get; set; }
}

I get an error:

The specified cast from a materialized 'System.Int32' type to the 'System.Boolean' type is not valid.

I think this might be because the stored procedure returns a number. How can I make it return a value that can be converted to the bool?

SELECT CAST(1 AS BIT) AS Authenticated

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM