Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Batch
- {
- public Guid Id { get; set; }
- public Item[] Items { get; set; }
- }
- public class Item
- {
- public int Id { get; set; }
- public string Description { get; set; }
- }
- Map = batches =>
- from batch in batches
- from item in batch.Items
- select new Result
- {
- Description = item.Description,
- ItemIds = new[] {item.Id}
- };
- Reduce = results =>
- from result in results
- group result by result.Description into g
- select new Result
- {
- Description = g.Key,
- ItemIds = g.SelectMany(x => x.ItemIds).ToArray()
- };
- Map = batches =>
- from batch in batches
- from item in batch.Items
- select new Result
- {
- Description = item.Description,
- ItemIdsAsString = item.Id.ToString(),
- };
- Reduce = results =>
- from result in results
- group result by result.Description into g
- select new Result
- {
- Description = g.Key,
- ItemIdsAsString = string.Join("|", g.Select(x => x.ItemIdsAsString)),
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement