Harlem 98

Harlem 98

  • NA
  • 161
  • 18.9k

Cannot implicitly convert type System.Collections.Generic.List

Dec 7 2021 11:08 AM

Hello community

I'm facing an issue "calling" a select method in class.

I have the following Select method in BLL

public List GetAllFiles(int IDRecursoHumano = 0)
{
try
{
using (GestaoProjectosEntities lt = new GestaoProjectosEntities())
{
var query = lt.ListagemTimesheets.Include("RecursoHumano").Include("EstadoTimesheet").AsQueryable();
if (IDRecursoHumano > 0)
query = query.Where(a => a.IDRecursoHumano == IDRecursoHumano);
return query.ToList();}
}
catch (Exception ex)
{
//
log.Error("BLL => GetAllFiles:" + ex.Message);return new List();
}
} 

And in my view.CS

if (e.CommandName == "EditItem")
{
    try
    {
        divUC.Visible = true; //divUC
        e.Canceled = true;
        int idTms = int.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString());
        model ts= BLL.GetAllFiles(idTms);
        divT.EditObject= ts;
        divT.DataBind();
    }
}

And i am getting error in line 10 "Cannot implicitly convert type System.Collections.Generic.List to 'modelclass'.

How can i overcome this?


Answers (1)