I have a HTTP GET Web API method that returns a list and got this error when it was called concurrently by a process it returned this error: Destination array was not long enough. Check destIndex and length, and the array's lower bounds.
public List<ItemList> GetAllItems(int Id)
{
List<ItemList> items = new List<ItemList>();
var itemsToPutIntoNewList = _unitOfWork.ItemRepo.All.Where(x => x.Id== Id).ToList();
foreach (var item in itemsToPutIntoNewList )
{
items.Add(new ItemList
{
ItemId= item.Id,
Name = item.Name,
Color = item.Feature.Color,
DateReteived = Datetime.Now
});
}
return items;
}
What's the best way to handle this potential error?