Skip to content

Instantly share code, notes, and snippets.

@betobaz
Created June 21, 2012 15:42
Show Gist options
  • Save betobaz/2966537 to your computer and use it in GitHub Desktop.
Save betobaz/2966537 to your computer and use it in GitHub Desktop.
Consulta con Linq con agrupadores dinamicos
from d in Vt_cxc_docs_clas2
where Math.Round((double)d.Saldo, 2, MidpointRounding.AwayFromZero) != 0
group d by new{
agrupador = "ClasificacionContable" == "" ? d.Desc_clas :
"Corporativo" == "Corporativo" ? d.Nom_corp :
"ClasificacionAlterna" == "" ? d.Des_clas2:
"TipoImpuesto" == "" ? d.Des_impto:
"CondicionPago" == "" ? d.Des_cnd_pag:
"MedioEnvio" == "" ? d.Des_med_env:
"Vendedor" == "" ? d.Nom_vendedor:
"TipoCliente" == "" ? (d.Tip_cli == 1 ? "Persona moral" : (d.Tip_cli == 2 ? "Persona física" : "")):
""
} into d1
select new{
Agrupador = d1.Key.agrupador,
Saldo = d1.Sum(vca => vca.Saldo),
Importe = d1.Sum(vca => vca.Importe),
TotalBase = d1.Sum(vca => vca.Totalbse),
SaldoBase = d1.Sum(vca => vca.Saldo_bse)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment