public TaskSummaryIndex() { Map = docs => from t in docs select new { t.Start }; IndexSortOptions.Add(s => s.Start, Raven.Abstractions.Indexing.SortOptions.String); }
public Answers_ByQuestion_NoTransformResults() { Map = docs => from doc in docs select new { AnswerId = doc.AnswerId, QuestionId = doc.QuestionId, VoteTotal = doc.Delta, DecimalTotal = doc.DecimalValue }; Reduce = mapped => from map in mapped group map by new { map.QuestionId, map.AnswerId } into g select new { AnswerId = g.Key.AnswerId, QuestionId = g.Key.QuestionId, VoteTotal = g.Sum(x => x.VoteTotal), DecimalTotal = g.Sum(x => x.DecimalTotal) }; IndexSortOptions.Add(x => x.VoteTotal, Raven.Abstractions.Indexing.SortOptions.NumericDefault); }
public TaskSummaryIndex() { Map = docs => from t in docs select new { t.Start }; TransformResults = (database, results) => from result in results let giver = database.Load <Raven.Tests.Bugs.LiveProjections.Entities.User>("users/" + result.GiverId) let taker = database.Load <Raven.Tests.Bugs.LiveProjections.Entities.User>("users/" + result.TakerId) let place = database.Load <Place>("places/" + result.PlaceId) select new { Id = result.Id, Description = result.Description, Start = result.Start, End = result.End, GiverId = result.GiverId, GiverName = giver.Name, TakerId = result.TakerId, TakerName = taker != null ? taker.Name : null, PlaceId = result.PlaceId, PlaceName = place.Name }; IndexSortOptions.Add(s => s.Start, Raven.Abstractions.Indexing.SortOptions.String); }
/// <summary> /// Register a field to be sorted /// </summary> protected void Sort(Expression <Func <TReduceResult, object> > field, SortOptions sort) { IndexSortOptions.Add(field, sort); }