I have a SP that returns a bit.
This is how it's called from my C# program using EF context:
bool productCount = context.Database
.SqlQuery<bool>("EXEC [dbo].[SP_Name] @CatogeryID,@Id",
new SqlParameter("CatID", lngCatid),
new SqlParameter("SId", lngStudentId)
).FirstOrDefault();
When the proc is run inside SQL MMS it gives correct result of True/False depending on the params.
The same proc always returns false when called.
What am I missing?
Any clues?
Perhaps it's something in your stored proc not doing the select properly? Sample working code:
CREATE PROCEDURE [dbo].[testProc]
@inval bit output
AS
BEGIN
declare @outval bit
select @outval = @inval
select @outval
END
using (var dbContext = new testContext())
{
var data = dbContext.Database.SqlQuery<bool>("exec testProc {0}",false).FirstOrDefault();
Console.WriteLine(data);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With