Wednesday, 22 June 2022

Return scalare value from storeprocedure using entity

 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

7 Common mistakes in Dot Net — You can avoid

  There are many common mistakes made during .NET (ASP.NET, .NET Core) development, which affect performance, security, and code… Code Crack...