I 'm try to call a store procedure with LinQ, but in the compilation moment, it show me the next message "foreach stament cannot operates on variables of type "Int", because "Int" Does contain a public definition for GetEnumerator"
What is This????, help me please......I look for on the web, but I can't find the solution
Stored Procedure
CREATE PROCEDURE sp_Busca_Vehiculos
@Patente varchar(6),
@Contract bigint
AS
BEGIN
SET @Patente =LTRIM(RTRIM(REPLACE(@Patente,'%','')))
DECLARE @PatenteParaLike varchar(8) ='%' + LTRIM(RTRIM(REPLACE(@Patente,'%',''))) + '%'
DECLARE @ContractSerialNumberParaLike nvarchar(30) = '%' + CONVERT(nvarchar(30),@Contract) +'%'
IF @ContractSerialNumber > 0 AND Len(@Patente) > 0 AND Len(@Patente) < 6
BEGIN
SELECT DISTINCT
h.serieNum CONtractSerialNumber,
ISNULL(v.patente,'') Patente,
ISNULL(v.marca,'') Marca,
ISNULL(v.modelo,'') Modelo,
es.descripciON EstadoTAG,
h.fecha_instalaciON FechaInstalaciONTag,
CASE
when h.fecha_baja > '19800101' THEN h.fecha_baja
ELSE ''
END FechaBajaTAG,
ISNULL(cl.descripciON, '') Lista,
ISNULL(li.fecha_lista,'') FechaLista,
ISNULL(v.id,'') id_vehiculo
FROM tag h
LEFT JOIN lista li ON h.id = li.id_tag
LEFT JOIN vehiculo v ON v.id = h.id_vehiculo
LEFT JOIN cONtrato_vehiculo cv ON cv.id_vehiculo = v.id
LEFT JOIN color cl ON cl.id = li.id_color
LEFT JOIN estado es ON es.id = h.id_estado
WHERE h.serieNum LIKE @ContractSerialNumberParaLike
or v.patente LIKE @PatenteParaLike
END
END
C# Code
public static List<BKReporteResult.BuscaVehiculos> BuscaVehiculos(string pstrPatente, long? plonContract)
{
List<BKReporteResult.BuscaVehiculos> listaResultados = new List<BKReporteResult.BuscaVehiculos>();
using (var contexto = new EF.ContextoBK(Config.Instance.ConexionBK, Config.Instance.ProxiCreationEnabled))
{
var data = contexto.sp_Busca_Vehiculos(pstrPatente, plonContract);
if (data != null)
data.ToList().ForEach(rpt => listaResultados.Add(Tools.Reflection.Cast<BKReporteResult.BuscaVehiculos>(rpt)));
}
return listaResultados;
}