I have created a variable that checks if a row in a database exists. However when I put the variable in an if statement to check if it's null and the variable is null it always goes to else instead of continuing the if statement.
Is there another way of checking if a variable is null instead of == null?
var following = objCtx.Followusers.Where(c => c.User1ID == currentUser.Id || c.User2ID == cus.Id);
if (following == null)
{
using (Html.BeginForm("Followruser", "Users"))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@Html.Hidden("Id", Id)
<input type="submit" value="follow" class="btn btn-default" />
}
}
else
{
using (Html.BeginForm("unfollowruser", "Users"))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@Html.Hidden("Id", Id)
<input type="submit" value="following" class="btn btn-default" />
}
}