public List <object> SendRequest(JSONParametrs request) { var Result = new List <object>(); using (IDbConnection dbConnection = GetDbConnection(request)) { dbConnection.Open(); if (!request.StoredProcedure) { Result = dbConnection.Query <object>(request.QueryString, null, null, true, request.TimeOutInSecond).ToList(); } else { var param = new DynamicParameters(); foreach (KeyValuePair <string, string> keyValue in request.ProcedureParam) { param.Add(keyValue.Key, keyValue.Value); } var ans = dbConnection.Query <object>(request.QueryString, param, commandType: CommandType.StoredProcedure).SingleOrDefault(); } } return(Result); }
public List <object> GetData(JSONParametrs request) { if (request.TimeOutInSecond == 0 || request.ConnectionString == string.Empty || request.QueryString == string.Empty) { return(null); } var answer = ServiceSQL.SendRequest(request); return(answer); }
private IDbConnection GetDbConnection(JSONParametrs parametrs) { switch (parametrs.TypeSql) { case TypeSql.MsSql: return(new SqlConnection(parametrs.ConnectionString)); case TypeSql.PostgreSql: return(new NpgsqlConnection(parametrs.ConnectionString)); default: return(null); } }