I get SonarCloud
error in this code:
foreach (var item in itemList)
{
if (string.IsNullOrEmpty(item.Name))
{
throw new BadRequestException("Item name is null or missing...");
}
if (someOtherList.Any(x => x.Name == item.Name))
{
throw new NotAcceptedException("Item name already exist in Db.");
}
}
My question is how to translate this code into LINQ
using Select
(as sonar suggest) when I have exceptions
?