.Net error in the model container

0

I can not see the error, I marked it in: = ctx.spObtieneCombustibleSinLiquidar_sUP(Operador); I tried everything:

ctx.spObtieneCombustibleSinLiquidar_sUP(Operador)
public List<CivarTransporteService.Model.SPObtieneCombustibleSinLiquidarResult> getCombustibleSinLiquidar(int Operador)
{
    using (CivarTransporteService.Model.SIAModelContainer ctx = new CivarTransporteService.Model.SIAModelContainer())
    {
        try
        {
            IEnumerable<CivarTransporteService.Model.SPObtieneCombustibleSinLiquidarResult> spResult =  ctx.spObtieneCombustibleSinLiquidar_sUP(Operador);
            return spResult.ToList();       
        }
        catch (Exception ex)
        {
            return null;
        }
    }
}

I add details:

namespace CivarTransporteService.Model
{
    using System;

    public partial class SPObtieneCombustibleSinLiquidarResult
    {
        public int Operador { get; set; }
    }
}

The Stored Procedure only requests the operator as a parameter.

    
asked by jm167 23.03.2017 в 20:13
source

1 answer

0

You are sending this error because the spObtieneCombustibleSinLiquidar_sUP method has a int as return value and you are expecting a IEnumerable<CivarTransporteService.Model.SPObtieneCombustibleSinLiquidarResult>

For this, there are two possible solutions:

  • The spObtieneCombustibleSinLiquidar_sUP method should return a variable of type IEnumerable<CivarTransporteService.Model.SPObtieneCombustibleSinLiquidarResult>
  • When invoking the spObtieneCombustibleSinLiquidar_sUP method, it should be done through a variable of type int , for example:

    int result = ctx.spObtieneCombustibleSinLiquidar_sUP(Operador);

  • answered by 23.03.2017 в 23:10