- public async Task
Details(Guid? id) - {
- if (id == null)
- {
- return NotFound();
- }
- ProductDetailViewModel productview = new ProductDetailViewModel()
- {
- productImages = await _context.ProductImages.FirstOrDefaultAsync( c => c.ProductId == id), //error
- productWithImagesDbs = await _context.ProductWithImagesDb.FirstOrDefaultAsync(m=> m.ProductId == id) // error
- };
- if (productview == null)
- {
- return NotFound();
- }
- return View(productview);
- }
the viewmodel:
- public class ProductDetailViewModel
- {
- public List
productWithImagesDbs { get; set; } - public List
productImages { get; set; } - }
- public class ProductImages
- {
- [Key]
- [Required]
- public Guid ProductId { get; set; }
- [Required]
- public string ImagePath { get; set; }
- [Required]
- public int ImageOrder { get; set; }
- }
- public class ProductWithImages
- {
- [Key]
- [Required]
- public Guid ProductId { get; set; }
- [Required]
- [Display(Name ="Product Title")]
- public string ProductTitle { get; set; }
- // etc...
Its probaly something really simple that i dont know about yet. but i can seem to figure it out
it gives the error : Cannot implicitly convert type Test4.Models.ProductImagesDb to System.Collections.Generics.List

Rijwan AnsariRank #82 · 24.2K reputationPosted Apr 3, 2021, 6:18 AM EDT
Suraj DubeyRank #2,182 · 647 reputationPosted Apr 3, 2021, 2:48 AM EDT
Satya KarkiRank #78 · 24.6K reputationPosted Apr 3, 2021, 6:22 AM EDT
osyris zosarRank #6,574 · 262 reputationPosted Apr 3, 2021, 5:19 AM EDT
osyris zosarRank #6,574 · 262 reputationPosted Apr 3, 2021, 6:54 AM EDT
the code looks much cleaner and I understand it much beter now.
Thank you so much!
Sachin SinghRank #66 · 26.2K reputationPosted Apr 3, 2021, 3:09 AM EDT