public ICollection <SizeDescription> GetAllSizes()
        {
            SqlDataReader reader = this.ExecuteReader(
                @"SELECT Id, Name
                     FROM Sizes");

            ICollection <SizeDescription> sizes = new List <SizeDescription>();

            using (reader)
            {
                while (reader.Read())
                {
                    int             sizeId   = reader.GetInt32(0);
                    string          sizeName = reader.GetString(1);
                    SizeDescription size     = new SizeDescription(sizeId, sizeName);

                    sizes.Add(size);
                }
            }

            return(sizes);
        }
Exemplo n.º 2
0
        public ICollection <SizeDescription> GetAllSizes()
        {
            var sizes  = new Dictionary <int, SizeDescription>();
            var reader = this.ExecuteReader(
                @"select Id, Name
                    from Sizes");

            using (reader)
            {
                while (reader.Read())
                {
                    int    sizeId   = reader.GetInt32(0);
                    string sizeName = reader.GetString(1);

                    if (!sizes.ContainsKey(sizeId))
                    {
                        sizes[sizeId] = new SizeDescription(sizeId, sizeName);
                    }
                }
            }

            return(sizes.Values);
        }