- 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 AnsariPosted Apr 3, 2021, 10:18 AM
osyris zosarPosted Apr 3, 2021, 10:54 AM
the code looks much cleaner and I understand it much beter now.
Thank you so much!
Satya KarkiPosted Apr 3, 2021, 10:22 AM
osyris zosarPosted Apr 3, 2021, 9:19 AM
Sachin SinghPosted Apr 3, 2021, 7:09 AM
Suraj DubeyPosted Apr 3, 2021, 6:48 AM