在这里,我试图将模型映射SliderImage
到视图模型SliderImageVM
并返回视图模型。
在SliderImage
模型中有
public string Image { get; set; }
在SliderImageVM
视图模型中我有
public IFormFile Photo { get; set; }
现在在将模型转换为视图模型时我有错误说
无法从字符串转换为 Microsft.AspNetCore.Http.IFormFile
下面是我的代码
public SliderImageVM GetSliderBySliderImageVMById(int sliderImageId)
{
var getSliderImage = uow.Repository<SliderImage>().FindBy(x => x.SliderImageId == sliderImageId).FirstOrDefault();
SliderImageVM newSliderImgeVM = new SliderImageVM
{
SliderImageId = getSliderImage.SliderImageId,
Photo = getSliderImage.Image, //<------Error in this line
};
return newSliderImgeVM;
}