Ejemplo n.º 1
0
        public override List <ProductoDTO> GetProductByName(string palabra)
        {
            ProductsData data = new ProductsData();

            IMongoCollection <BsonDocument>        products = data.GetProductDataByName();
            FilterDefinitionBuilder <BsonDocument> builder  = Builders <BsonDocument> .Filter;
            FilterDefinition <BsonDocument>        filter   = @"{ $or: [{ ""brand"" : {$in: [/$palabra$/] }},{ ""description"" : {$in: [/$palabra$/] }}] }".Replace("$palabra$", palabra);
            List <BsonDocument> resultFiltros = products.Find(filter).ToList();

            foreach (BsonDocument item in resultFiltros)
            {
                ProductoDTO myObj = BsonSerializer.Deserialize <ProductoDTO>(item);
                listResultDB.Add(myObj);
            }

            return(listResultDB);
        }