This is the SQL
that I have as an example, would you like to do the same with Linq
?
select SUM(iv.precoMediano * oi.quantidade) as total from orc_orcamentoItem oi
inner join orc_insumoValor iv on oi.codigo = iv.codigoSinapi
where oi.grupoPai = 1
group by oi.grupoPai
My main question here is: How to do Sum in linq using Fields from the two tables. For example: Sum (table1 => table1.quantity * table2.value)
Entities
Budget item
public int Item_id { get; set; }
public int Orcamento_id { get; set; }
public string Tipo_desc { get; set; }
public string Descricao { get; set; }
public int GrupoPai { get; set; }
public int Codigo { get; set; }
public decimal Quantidade { get; set; }
public string base_desc { get; set; }
Value Input
public int InsumoDados_id { get; set; }
public int InsumoValor_id { get; set; }
public int CodigoSinapi { get; set; }
public string OrigemPreco { get; set; }
public decimal PrecoMediano { get; set; }