Example #1
0
        private static List <T> LoadPivotTypeWithQuery <T>(string query, Func <MySqlDataReader, object[], T> action, params MySqlParameter[] parameters)
        {
            List <T> listofT = new List <T>();

            using (var sqlConnection = new MySqlConnection(GlobalAppConfig.GetConnectionString()))
            {
                sqlConnection.Open();
                using (var sqlCommand = sqlConnection.CreateCommand())
                {
                    sqlCommand.CommandText = query;
                    foreach (var parameter in parameters)
                    {
                        sqlCommand.Parameters.Add(parameter);
                    }
                    using (var sqlReader = sqlCommand.ExecuteReader())
                    {
                        while (sqlReader.Read())
                        {
                            listofT.Add(action.Invoke(sqlReader, new object[] { GlobalAppConfig.GetProfilePictureBaseDirectory() }));
                        }
                    }
                }
            }

            return(listofT);
        }
Example #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="configuration"><see cref="IConfiguration"/></param>
 public Startup(IConfiguration configuration)
 {
     GlobalAppConfig.Initialize(configuration);
     GlobalAppConfig.IsWtaContext = false;
     SqlMapper.LoadModel();
     GlobalAppConfig.IsWtaContext = true;
     SqlMapper.LoadModel();
 }
Example #3
0
 private static void LoadConfiguration()
 {
     using (var sqlConnection = new MySqlConnection(GlobalAppConfig.GetConnectionString()))
     {
         sqlConnection.Open();
         using (var sqlCommand = sqlConnection.CreateCommand())
         {
             sqlCommand.CommandText = "SELECT * FROM configuration WHERE id = @id";
             sqlCommand.Parameters.Add(new MySqlParameter("@id", MySqlDbType.UInt32)
             {
                 Value = GlobalAppConfig.GetInt32(AppKey.ConfigurationId)
             });
             using (var sqlReader = sqlCommand.ExecuteReader())
             {
                 if (sqlReader.Read())
                 {
                     ConfigurationPivot.Initialize(sqlReader);
                 }
             }
         }
     }
 }