I have a method MapResults
which returns IEnumerable<T>
and I have a list temp
. I want to add returnVal
and temp
lists and return IEnumerable<T>
.
public class RetrieverClass<T, TEntity> : IRetriever<T, TEntity>
where T : BaseFileEntity
where TEntity : class, IEntity<int>
{
public async Task<IEnumerable<T>> TestMethod(IEnumerable<Item> items)
{
var returnVal = MapResults(result).ToList();
List<TestEntity> temp = new List<TestEntity>();
foreach (var testNo in testNos)
{
TestEntity test = CreateTestEntity(testNo);
temp.Add(test);
}
returnVal.AddRange(temp);
}
private IEnumerable<T> MapResults(IEnumerable<TEntity> results)
{
return results.Select(x => _repository.ObjectMapper.Map<T>(x));
}
}
public class TestEntity : BaseFileEntity
{
}
But its giving error on line returnVal.AddRange(temp)
.
cannot convert from
System.Collections.Generic.List<TestEntity>
toSystem.Collections.Generic.IEnumerable<T>