This question is locked. New answers and comments are not allowed.
Does anyone know how to use named parameters instead of numbered? I can see quite a few examples that use numbered parameters using ?. e.g.,
This is hell on my maintenance and really error prone. Is there any way to use named parameters? Like this:
I know you can use LINQ, but is there any SQL/OQL support for named parameters?
Thanks,
Joel
| string query = "SELECT * FROM users where email=? or username=?"; Query<User> command = scope.GetSqlQuery<User>(query, "varchar email, varchar username"); QueryResultList<User> result = command.ExecuteList(emailUser, emailUser); |
This is hell on my maintenance and really error prone. Is there any way to use named parameters? Like this:
| SqlCommand mySqlCommand = mySqlConnection.CreateCommand(); |
| mySqlCommand.CommandText = |
| "INSERT INTO Employee (" + |
| " ID, FirstName, LastName" + |
| ") VALUES (" + |
| " @ID, @FirstName, @LastName" + |
| ")"; |
| mySqlCommand.Parameters.Add("@ID", SqlDbType.NChar, 2); |
| mySqlCommand.Parameters.Add("@FirstName", SqlDbType.NVarChar, 10); |
| mySqlCommand.Parameters.Add("@LastName", SqlDbType.NVarChar, 10); |
I know you can use LINQ, but is there any SQL/OQL support for named parameters?
Thanks,
Joel