0

I tried to execute a stored procedure in my console application but what I get is a print of the sentence I want to call.

My stored procedure that I have created:

create proc Checked
@Links nvarchar(MAX)
as
SELECT CASE 
WHEN EXISTS (
    SELECT ID
    FROM News
    WHERE LinkNews = @Links
)
THEN CAST(1 AS BIT)
ELSE CAST(0 AS BIT) END

And the method that I used to call the stored procedure inside the Console Application:

using (DbContextClass db = new DbContextClass())
{
    SqlParameter p = new SqlParameter("@Links", "http://www.newsline-ye.com/news7527.html");
    IEnumerable<New> n = db.Database.SqlQuery<New>("exec Checked @Links", p);
    Console.WriteLine(n);               
}
Console.ReadKey();

My Problem It gives me this output "exec Checked @Links" sentence

Can anyone help me to solve my problem?

1 Answers1

0
List<SqlParameter> sqlParameters = new List<SqlParameter>()
{
    new SqlParameter("Links", p);
}

string query = "EXECUTE Checked @Links";

var result = db.Database.SqlQuery<bool>(query, sqlParameters.ToArray());
Voodoo
  • 1,550
  • 1
  • 9
  • 19