I am facing a strange issue, i am not sure what happened to code, it was working perfectly yesterday. I have data in table and am using below function to retrieve it from DB. i am using My SQL. when the application is started the data fetch correctly, but once we hit few times to DB for some tractions like save/update/delete. it stops to fetch records from DB or you can say it stops communicate with DB, but it the connection is building. i have verified that.
Below is my code:
public List<AcademyTeamsEntity> GetAcademyTeams(int academyId)
{
using (IDbConnection db = new MySql.Data.MySqlClient.MySqlConnection(ClsConnectionString.connectionString))
{
string query = @"SELECT * FROM academyteams where AcademyId=" + academyId + " order by CategoryId asc ";
return db.Query<AcademyTeamsEntity>(query, commandType: System.Data.CommandType.Text).ToList();
}
}
Please suggest what is the mistake i am making. thanks in advance.
It looks like problem with transactions.
Maybe transaction level is set to serializable. And it locks all data untill completed, and You get deadlock after sending few requests with save/update/delete methods.
Check if Your transactions always complete or rollback if something is wrong, and that You close all connections and transactions to db in methods with transactions.