예제 #1
0
 public IEnumerable <T> getAllDataList(T t)
 {
     try
     {
         string strSQL = $"SELECT * FROM {t.GetType().Name} WHERE 1=1 ";
         log.Debug(strSQL);
         if (transaction == null)
         {
             IEnumerable <T> ret = sqlConnection.Query <T>(strSQL);
             sqlConnection.Close();
             return(ret);
         }
         else
         {
             return(sqlConnection.Query <T>(strSQL, null, transaction));
         }
         //return sqlConnection.Query<T>(strSQL);
     }
     catch (Exception ex)
     {
         log.Error(ex);
         throw ex;
     }
 }
예제 #2
0
        public List <T> Get <T>(string connection, string sql, object parameters)
        {
            var result = new List <T>();

            //var test = new MySql.Data.MySqlClient()
            using (var c = new MySqlData.MySqlConnection(connection))
            {
                _log.LogTrace <MySqlQuery>($"SELECT: {sql}. Connection: {connection}. Parameters: {JsonConvert.SerializeObject(parameters)}");

                c.Open();

                result = c.Query <T>(sql, parameters).ToList();

                c.Close();
            }

            return(result.ToList());
        }