Skip to content

Instantly share code, notes, and snippets.

@jpolvora
Created July 20, 2015 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpolvora/dd5018d8fb749f9f3198 to your computer and use it in GitHub Desktop.
Save jpolvora/dd5018d8fb749f9f3198 to your computer and use it in GitHub Desktop.
public class Dto
{
public int Formato1 { get; set; }
public int Formato2 { get; set; }
public Embalagem Embalagem { get; set; }
public string Produto { get; set; }
public decimal QtdeTotal { get; set; }
public static IEnumerable<Dto> Teste(ArmazemCtx context)
{
var result = context.ItensConferidos
.Include(x => x.ItensPalets)
.Include(x => x.ItemEntrada)
.Include(x => x.ItemEntrada.Produto)
.GroupBy(x => new
{
x.ItemEntrada.Produto.Nome,
x.Formato1,
x.Formato2,
x.Embalagem
})
.Select(s => new Dto
{
Formato1 = s.Key.Formato1,
Formato2 = s.Key.Formato2,
Embalagem = s.Key.Embalagem,
Produto = s.Key.Nome,
QtdeTotal = s.Sum(y => y.ItensPalets.Sum(z => z.Quantidade))
}).ToList();
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment