Perform direct consultation

0

I have my next query in c # I'm using the ADO.NET Entity Framework 4, my query I just want to get the data of two specific columns.

     public List<clsSalidas> Listar()
    {
        try
        {
            var lista = contexto.ExecuteStoreQuery<clsSalidas>("Select T_Doc, C_F from SALIDASDOC");
            return lista;
        }
        catch (Exception)
        {

            throw;
        }
    }

but it shows me the following message

No se puede convertir implícitamente el tipo
'System.Data.Objects.ObjectResult<Entidades.clsSalidas>' en 
 'System.Collections.Generic.List<Entidades.clsSalidas>'

As you can see, I can not find how to solve it. I hope you help me.

    
asked by SoyKrut 06.01.2018 в 20:45
source

1 answer

2

Most likely, your query is not returning a list, if nothing else, it is most likely that this is returning an enum, simply add ToList () to the query method.

 contexto.ExecuteStoreQuery<clsSalidas>("Select T_Doc, C_F from SALIDASDOC").ToList();

If your problem is not solved like this, I recommend you debug your program and place a breakpoint there, so you can see what type of variable returns and you can do the conversion

    
answered by 07.01.2018 / 01:19
source