Try this Code :
$productcollectionclass HelloWorld extends \Magento\Framework\View\Element\Template
{
protected $_productCollectionFactory;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
array $data = []
)
{
$this->_productCollectionFactory = $productCollectionFactory;
parent::__construct($context, $data);
}
public function getProductCollection()
{
$collection = $this->_objectManager>_productCollectionFactory->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
$productcollection $collection->addAttributeToSelect('*');
$collection->addFieldToFilter('my_attribute_code', array('in' => array(12,10)));
return $collection;
}
}