Closed viniciusdesa closed 3 years ago
I put a bug in ProductRepository.GetProductsByCategory:
Wrong
public async Task<IEnumerable<Product>> GetProductsByCategory(string categoryName)
{
FilterDefinition<Product> filter = Builders<Product>.Filter.ElemMatch(p => p.Category, categoryName);
return await _context
.Products
.Find(filter)
.ToListAsync();
}
Fixed
public async Task<IEnumerable<Product>> GetProductsByCategory(string categoryName)
{
FilterDefinition<Product> filter = Builders<Product>.Filter.Eq(p => p.Category, categoryName);
return await _context
.Products
.Find(filter)
.ToListAsync();
}
Thanks @viniciusdesa for sharing this. Also I had developed wrong one in first pace, but after that as you fixed, I had fixed with Eq method; https://github.com/aspnetrun/run-aspnetcore-microservices/blob/37f4198b8dd36e980e4fdede6c4d607c325c1610/src/Services/Catalog/Catalog.API/Repositories/ProductRepository.cs#L46
Hi,
I followed the course with all the steps from version 3.1 until the video 22. Developing Presentation Layer - Create CatalogController Class for Catalog.API. When I opened the course today, I realized that you updated the videos to .Net 5. I followed them in order to make it compatible (added Swashbuckle support, made some minor changes in Startup.cs and tried to run as you indicated). When I run the microservice, it opens and the methods work except GetProductByCategory. It returns the following Exception:
What could be wrong? Follow a link to my code: https://github.com/viniciusdesa/udemy-microsvcs-arch-n-impl/tree/master/Udemy_MicroservicesArch/src/Catalog/Catalog.API
Best regards,
Vinicius