I am trying to convert one model into another model that is a slightly different format. I was thinking I could do this in one line without a foreach by using LINQ however I keep running into an error about conversion of types. Here is my code:
ToRecipients = new List<Recipient>().AddRange<Recipient>(email.To.Select(contact => new Recipient
{
EmailAddress = new EmailAddress
{
Address = contact.EmailAddress,
},
}));
The error I am running into is :
Argument 2: cannot convert from 'System.Collections.Generic.IEnumerable<Microsoft.Graph.Models.Recipient>' to 'System.ReadOnlySpan<Microsoft.Graph.Models.Recipient>'CS1503
I am not sure what exactly I am doing wrong here as it seemed straight forward. I am looping through my email model and creating a new ms graph recipient object which is returning to the range. Any help would be appreciated!