public static ReportTemplateDto AsDto(this ReportTemplate entity) { var modules = entity.GetArray(); return(new ReportTemplateDto { Id = entity.Id, Title = entity.Title, Questionnaires = modules .OfType <QuestionnaireModuleTemplate>() .Select(x => x.AsDto()) .ToArray(), Tables = modules .OfType <TableModuleTemplate>() .Select(x => x.AsDto()) .ToArray() }); }