У меня ниже классов
public class ArtifactRole
{
public int ArtifactId { get; set; }
public IReadOnlyList<ClientRoleLookup> Roles { get; set; }
}
public class ArtifactRoleCollection : KeyedCollection<int, ArtifactRole>
{
protected override int GetKeyForItem(ArtifactRole item)
{
return item.ArtifactId;
}
}
, тогда у меня есть метод, подобный приведенному ниже
public Task<ArtifactRoleCollection> GetRoles(params int[] artifactIds)
{
var result = this.context.Events.Where(e => artifactIds.Contains(e.ID))
.Select(obj => new ArtifactRole{ ArtifactId = obj.EventId, Roles = obj.ClientRoleIds.ToList().AsReadOnly() })
;
return ????
}
Мой вопрос заключается в том, как вернуть экземпляр и вернуть ArtifactRoleCollection
без циклического прохожденияэлементы в foreach