Reputation: 117
I want to allow the user to add as many image URL's as they want.
So I made a class in Asp.Net Core razor pages Web App. Here is my current Code:
public class Post
{
public int ID { get; set; }
public string Text { get; set; }
public List<string> Url { get; set; }
public string Date { get; set; }
}
When I try to create the actual razor pages using scafolding and selecting this model as the model of the page, it gives me this error: Error-Image
why this happens? and what should i do to fix it?
Upvotes: 3
Views: 1513
Reputation: 1350
If each product can have multiple images, you have a one-to-many relationship and the image paths needs their own table. You should create an new class:
public FilePath
{
public int ID {get;set;}
public string Path {get;set;}
}
Then the ImagePath property will look like this:
public List<FilePath> ImagePath {get;set;}
However, if each product only has one image, your property shouldn't be a collection:
public string ImagePath {get;set;}
Upvotes: 1