У меня есть следующая модель ответа
public class GetMediaTypesReponse
{
public List<Dictionary<string,string>> Mediatypes { get; set; }
}
и следующая бизнес-логика
public async Task<GetMediaTypesReponse> GetMediaTypes()
{
GetMediaTypesReponse response = new GetMediaTypesReponse();
response.Mediatypes = new List<Dictionary<string, string>>();
IList<Media> medias = await mediaRepository.GetAllAsync();
foreach ()
{
}
return await Task.FromResult(response);
}
public class Media
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid MediaId { get; set; } // Using GUID as this table might have historical data without removing of records
public int MediaTypeId { get; set; } // for future Use like Banner image
public string ThumbnailImg { get; set; }
public string Image { get; set; }
public bool IsActive { get; set; }
public bool IsHeroImage { get; set; } //Will be displaced first
public string ImageText { get; set; } //Text to find images
public string ImageFileName { get; set; } //Uploaded image filename
}
Мне нужно создать один объект словаря для каждого цикла И затем добавить этоперечислить объект Поскольку нам не нужно передавать параметры в конструктор объекта словаря Там у нас нет возможности передать параметры в конструкторе.