示例#1
0
        public static List <CatalogItem> GetByManufacturer(string manufacturer)
        {
            List <CatalogItem> catalogItemList = new List <CatalogItem>();

            using (ObjectConnection objectConnection = new ObjectConnection())
            {
                using (GetCatalogItemByManufacturerCommand objectCommand = new GetCatalogItemByManufacturerCommand(objectConnection))
                {
                    objectCommand.Manufacturer = manufacturer;

                    objectConnection.Open();
                    using (SqlDataReader sqlDataReader = objectCommand.ExecuteReader())
                    {
                        if (!sqlDataReader.HasRows)
                        {
                            return(catalogItemList);
                        }

                        using (CatalogItemSqlDataReader objectSqlDataReader = new CatalogItemSqlDataReader(sqlDataReader))
                        {
                            while (objectSqlDataReader.Read())
                            {
                                catalogItemList.Add(objectSqlDataReader.CatalogItem);
                            }
                        }
                    }
                }
            }

            return(catalogItemList);
        }
示例#2
0
        public static CatalogItem GetByItemName(string itemName)
        {
            CatalogItem catalogItem = new CatalogItem();

            using (ObjectConnection objectConnection = new ObjectConnection())
            {
                using (GetCatalogItemByItemNameCommand objectCommand = new GetCatalogItemByItemNameCommand(objectConnection))
                {
                    objectCommand.ItemName = itemName;

                    objectConnection.Open();
                    using (SqlDataReader sqlDataReader = objectCommand.ExecuteReader())
                    {
                        if (!sqlDataReader.HasRows)
                        {
                            return(catalogItem);
                        }

                        using (CatalogItemSqlDataReader objectSqlDataReader = new CatalogItemSqlDataReader(sqlDataReader))
                        {
                            while (objectSqlDataReader.Read())
                            {
                                catalogItem = objectSqlDataReader.CatalogItem;
                            }
                        }
                    }
                }
            }

            return(catalogItem);
        }