User-821857111 posted
All of this is null : ProductBarcodes, ProductCategory, ProductInternationalization ,ProductImages
,ProductStock .
They are null because that is the default value for those types if you haven't instantiated them. You can instantiate collections by using an expression:
public class ProductModel
{
public virtual int ProductModelId { get; set; }
public string ProductIdid { get; set; }
public List<BarcodesModel> ProductBarcodes { get; set; } = new List<BarcodesModel>();
public CategoriesModel ProductCategory { get; set; }
public InternationalizationModel ProductInternationalization { get; set; }
public List<ImagesModel> ProductImages { get; set; } = new List<List<ImagesModel>();
public StockModel ProductStock { get; set; }
}
Now you can use Any() to test your collections:
if(ProductImages.Any())
{
....
But you still need to test for null for your other properties.