예제 #1
0
        /// <summary>
        /// Get all users in a list
        /// </summary>
        /// <returns></returns>
        public List <User> GetUsers()
        {
            List <User> UsersList = new List <User>();

            using (SqlConnection connection = DB.GetSqlConnection())
            {
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = @"ListAllUsers";
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        User User = new User();
                        User.Load(reader);
                        UsersList.Add(User);
                    }
                }
            }

            return(UsersList);
        }