Bheema Vidyuth

Bheema Vidyuth

  • 1.5k
  • 560
  • 148.5k

How to convert List object in to model in .net core?

Jun 10 2021 5:00 PM

i have a model class

 public class Data

        public string Id { get; set; }

        public string name{ get; set; }




i am getting a dataset using and i am getting to below method using  _DataAccessHelper. i am not allowed to change the method like  public List<Data>GetResults(string ServiceName)

    public async Task<Data>  GetResults(string ServiceName)
            var result = _DataAccessHelper.GetdataResults(ServiceName);

            var DataList = result.Tables[0].AsEnumerable()
     .Select(dataRow => new RegressionData
         Name = dataRow.Field<string>("Name")


            return DataList ;   //cannot return because i cannot pass as a list

cannot give according to my project structure    public List<Data>  GetResults(string ServiceName)



Can anyone help me...cs0029 cannot implicitly convert type list to model

Answers (1)