Hello, when the loop below runs, I need to add elements continuously.
I tried to do something like this but it didn't work. How can I solve this problem.
then i want to pull the data collected in the list.
C#
oreach (var item in products)
{
List list = new List();
list.Add(from p in models
select new
{
label = p.Name,
producturl = Url.RouteUrl("Product", new { SeName = p.SeName }),
productpictureurl = p.DefaultPictureModel.ImageUrl
};
result = models.Where(x => x.Id == item.Id).Select(p => new
{
label = p.Name,
producturl = Url.RouteUrl("Product", new { SeName = p.SeName }),
productpictureurl = p.DefaultPictureModel.ImageUrl
}).ToList();
}C#
public class Urunler
{
public string Pname { get; set; }
public string Url { get; set; }
public string Photo { get; set; }
}
Sachin SinghRank #66 · 26.2K reputationPosted Nov 23, 2021, 4:22 AM EST
Ali Ylmaz151 reputationPosted Nov 23, 2021, 5:08 AM EST