I am using SQL Server and WebMatrix Razor syntax to try and determine is a username is contained within a table called Users.
The logic I wish to have is :
bool usernameExists = db.QueryValue("SELECT Username from Users where Username = ?", username);
if(usernameExists.IsEmpty()){ //username is not in table
Response.Redirect("Register.cshtml");
}
What is the best practice for going about this?
Simplest is probably:
Though I’m speaking strictly from the SQL Server side. I don’t know if this is the best approach from the C# side.