0

I have a stored procedure which returns a single date string based on some logic with no column name.

SQL Output window

My C# code using entiry framework

public string GetCurrTimeForUser(string userId)
    {

        using (var context = new RMTest())
        {
            var user_id = new SqlParameter("@USER_ID", userId);

            var result = context.Database.SqlQuery<string>("EXEC PROC_GET_UTC_DATE",user_id);
            return result.ToString();
        }
    }

and the output I am getting is "EXEC PROC_GET_UTC_DATE";

What is wrong with my approach?

Jyotirmaya Prusty
  • 278
  • 1
  • 8
  • 25

1 Answers1

-1

When calling a stored procedure:

var result = context.Database.SqlQuery("EXEC PROC_GET_UTC_DATE '" + user_id + "'")

It's almost like that

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Vijunav Vastivch
  • 4,153
  • 1
  • 16
  • 30