Gnanavel Sekar

Gnanavel Sekar

  • NA
  • 8.4k
  • 7.3m

Cannot Convert from Tasks.Task to Generic.List

Jul 31 2017 9:39 AM
Hi Friends,
 
Am getting the error as below"
Error CS1503 Argument 1: cannot convert from 'System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Model.Patient>>' to 'System.Collections.Generic.List<Model.Patient>'
 
this.ViewLogs = new ObservableCollection<LogInfo>(Task.Run(async () => await this.GetLogDetails())); 
 
 
 
 
private async Task<IEnumerable<LogInfo>> GetLogDetails()
{
this.ViewLogs = new ObservableCollection<LogInfo>();
var listofLogs = await this.dataManager.LoggerRepository.GetAllLogsAsync();
if (listofLogs != null && listofLogs.Count() > 0)
{
foreach (var logs in listofLogs)
{
this.ViewLogs.Add(new LogInfo
{
CreationDate = logs.CreationDate,
Id = logs.id,
Levels = logs.Levels,
Logger = logs.Logger,
Message = logs.Message,
ImageLevel = this.SelectImageLevels(logs.Levels),
});
}
}
return this.ViewLogs;
}
 
 
How to resolve this error?
 
 
Thanks in advance 

Answers (1)