C#C
C#3y ago
K0unna

✅ I get Internal Server Error when uses Include

[HttpGet]
        public async Task<ICollection<Product>> Get()
        {
            var reviews = await _context.reviews.ToListAsync();
            var products = await _context.products.ToListAsync();
            List<ProductReviewModel> PRML = new List<ProductReviewModel>();
            foreach (var i in products)
            {
                ProductReviewModel PRM = new ProductReviewModel()
                {
                    Product = i
                };

                PRM.Review = reviews.FindAll(x => x.ProductId == i.Id);

                PRML.Add(PRM);
            }
            return products;
        }

In this code I get InternalServerError. Also if I use Include instead of whole this code, then I get InternalServerError again
Was this page helpful?