Пример #1
0
        public static ObservableCollection <BaseEntity> getPaginated(int start = 0, int number = 25)
        {
            ObservableCollection <BaseEntity> companies = new ObservableCollection <BaseEntity>();

            using (var connection = DatabaseConnection.Instance.Connection)
            {
                MySqlCommand command = new MySqlCommand(
                    $"SELECT * FROM company LIMIT {start},{number};",
                    connection
                    );
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Company company = new Company(reader);
                    companies.Add(company);
                }
                reader.Close();
            }
            foreach (Company company in companies)
            {
                Address address = AddressDataAccessObject.getAddressById(company.AddrId);
                company.address = address;
            }


            return(companies);
        }
Пример #2
0
        public static ObservableCollection <BaseEntity> getPaginated(int start = 0, int number = 25)
        {
            ObservableCollection <BaseEntity> people = new ObservableCollection <BaseEntity>();

            using (var connection = DatabaseConnection.Instance.Connection)
            {
                MySqlCommand command = new MySqlCommand(
                    $"SELECT * FROM person LIMIT {start},{number};",
                    connection
                    );
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Person person = new Person(reader);
                    people.Add(person);
                }
                reader.Close();

                foreach (Person person in people)
                {
                    Address address = AddressDataAccessObject.getAddressById(person.AddrId);
                    person.address = address;
                }
            }
            return(people);
        }
Пример #3
0
        public static Company getById(long id)
        {
            Company company = null;

            using (var connection = DatabaseConnection.Instance.Connection)
            {
                MySqlCommand command = new MySqlCommand(
                    $"SELECT * FROM company WHERE id={id}",
                    connection
                    );
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    company = new Company(reader);
                }
                reader.Close();
            }

            Address address = AddressDataAccessObject.getAddressById(company.AddrId);

            company.address = address;
            return(company);
        }
Пример #4
0
        public static Person getById(long id)
        {
            Person person = null;

            using (var connection = DatabaseConnection.Instance.Connection)
            {
                MySqlCommand command = new MySqlCommand(
                    $"SELECT * FROM person WHERE id={id}",
                    connection
                    );
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    person = new Person(reader);
                }
                reader.Close();
            }
            Address address = AddressDataAccessObject.getAddressById(person.AddrId);

            person.address = address;

            return(person);
        }