public class HomeownerRegistrations_AverageCost : AbstractIndexCreationTask<HomeownerRegistration, HomeownerRegistrations_AverageCost.Result>
{
public class Result
{
public decimal Cost { get; set; }
public int Count { get; set; }
}
public HomeownerRegistrations_AverageCost()
{
Map = homeownerRegistrations =>
from homeowner in homeownerRegistrations
where homeowner.Status.StartsWith("Paid")
select new
{
Cost = homeowner.Receipts.GrandTotal,
Count = 1
};
Reduce = results =>
from result in results
group result by 0
into g
let cost = g.Sum(x => x.Cost)
let count = g.Sum(x => x.Count)
select new
{
Cost = cost/count,
Count = count
};
}
}
Hibernating Rhinos Ltd
Grisha Kotler l RavenDB Core Team Developer l Mobile: +972-54-586-8647
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
RavenDB paving the way to "Data Made Simple" http://ravendb.net/
David--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
David--