I'm developing an API for my android app.
I'm using the API for accessing MySql from android via Asp.Net.
Like this,
[Route("api/v1/getMethodExample")]
[HttpGet]
public int GetMethodExample(string parametre)
{
mySqlConnection = new MySqlConnection("");
mySqlConnection.Open();
...
//Do something with mysql
int value = mySqlConnection.get("myTable","4");//in example
mySqlConnection.Close();
return value;
}
In short, for every web API call, I'm connecting MySql, getting data and closing MySql.
Is this right way?