我想執行下面的代碼。我的目標是檢查是否存在具有給定電子郵件ID的用戶。實體框架:'SqlParameter已經包含另一個SqlParameterCollection'
var result = userDbContext.users.SqlQuery("SELECT * FROM USERS WHERE @email='@emailValue'",
new SqlParameter("@email", "email"),
new SqlParameter("@emailValue","[email protected]"));
//new SqlParameter("p1", existingUser.password));
if (result.Count() == 0) //getting exception here
{
ViewBag.comment = "Sorry. We can not find your credentials";
return View();
}
但我在result.count()
越來越異常,不知道什麼錯誤。
的例外是:
我該如何解決這個 「SqlParameter有已被另一 SqlParameterCollection載」?
你不能參數你的列名,你可以參數你的值。 –