问题描述
我想创建一个多图像上传文件。我想这样创建:http://learningprogramming.net/net/asp-net-core-mvc/multiple-file-upload-in-forms-in-asp-net-core-mvc/
test.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Practise.Models
{
public class test
{
public string Id { get; set; }
public string Name { get; set; }
public double Price { get; set; }
public List<string> Photos { get; set; }
}
}
错误:
解决方法
您需要建立一对多关系,对多张照片进行一次测试,因此您需要在数据库中具有两个表。 您可以这样设置模型:
public class test
{
public string Id { get; set; }
public string Name { get; set; }
public double Price { get; set; }
public List<Photo> Photos { get; set; }
}
public class Photo
{
public string PhotoId { get; set; }
public string Path { get; set; }
}