Created
July 20, 2015 21:16
-
-
Save jpolvora/dd5018d8fb749f9f3198 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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