I have this query in LinQ, I filled the object with the query but it does not complete an object variable.
The model of Retención
has a variable Empresa
that is another model, and is the one that does not fill, remains null:
public class Retencion
{
public int ID { get; set; }
public int Año { get; set; }
public string Nit { get; set; }
public string Nombre { get; set; }
public string Direccion { get; set; }
public string Telefono { get; set; }
public int Tipo { get; set; }
public string Cuenta { get; set; }
public string Concepto { get; set; }
public int Base { get; set; }
public int Porcentaje { get; set; }
public int Valor { get; set; }
public Empresa Empresa { get; set; }
public int EmpresaId { get; set; }
}
public List<Retencion> Get(string nit, string ano)
{
List<Retencion> result = new List<Retencion>();
int a = Convert.ToInt32(ano);
try
{
result = (from p in _context.Retencion
join e in _context.Empresa on p.EmpresaId equals e.ID
where (p.Año == a && p.Nit == nit)
select p).ToList();
}
catch (Exception e)
{
e.ToString();
}
return result;
}