Entity framework with oracle developer. Validate the user

-1

// Button Event

protected void LoginButton_Click1(object sender, EventArgs e)
{
   bool existe;

   string query = "SELECT COUNT(*) FROM USUARIO WHERE login= :p_login AND password= :p_password ";
        cmd.Parameters.Add(":p_login", OracleType.VarChar).Value = this.Login1.UserName.ToString();
        cmd.Parameters.Add(":p_password", OracleType.VarChar).Value = this.Login1.Password.ToString();

    //int valor = Convert.ToInt32(cmd.ExecuteScalar());


    using (EntitiesOracle context = new EntitiesOracle())
    {
        existe = db.Usuarios.Any(x => x.DNI = dni && x.password = password);
    }

    if (existe)
    {
        //pasa la autenticacion
    }
}

QUESTION: what do you need or is it better to implement it with a procedure? I appreciate your help, thank you.

    
asked by Jose Daviid Mt 24.07.2018 в 19:39
source

1 answer

0

based on opinions, but for the most part it is always better to have the SQL code in stored procedures and functions for various reasons

  • Compile time
      

    The store procedures are already compiled, so they only wait for parameters to be executed, coding the query directly in code will make that each time that and invoke it has to recompile

  • Visibility of the Code
      

    This depends if you want the developers to see the SQL queries you are running, usually the only thing that the developer needs is to know the input parameters and the results, the rest is at the discretion of the DBA

  • Code Control
      

    and this is the most important, YOU DO NOT WANT TO MAINTAIN THE CHANGES IN THE DATABASE IN YOUR APPLICATION CODE (I would put this in red if I could)
      The main problem with this is that if you need to make changes to the query you must do it directly from the code of your app and this requires compiling and redistributing your executable, if the query lives in a store procedure you only need to change it from your database. data and while the input and output parameters remain the same then you will not have to modify the original application.

  • answered by 24.07.2018 в 21:39