Today issue is to return scalare value from storeprocedure using entity .
>>i have tried excuted the count value in asp.net core but unable to find solution
>> i used dapper using the excuted the scaler value done in the dbcontext
moreover dapper is faster than context.
read this dapper file for clear
https://www.learndapper.com/selecting-scalar-values
public int GetUnReadMessageCount(long userID)
{
var sql = "exec [Web].[usp_NotificationRecordCount] @MemberID";
var values = new { MemberID = userID };
using (var connection = new SqlConnection(configuration.GetConnectionString("FMSWebApiTestContext")))
{
connection.Open();
var count = Convert.ToInt32(connection.ExecuteScalar(sql,values));
return count;
}
}
No comments:
Post a Comment