I'm just getting started with Raven and an index I've created keeps failing to index anything. I've found a lot of errors on the Raven server that look like this:
{
Index: "HomeBlurb/IncludeTotalCosts",
Error: "Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)",
Timestamp: "2012-01-14T15:40:40.8943226Z",
Document: null
}
The index I've created looks like this:
public class HomeBlurb_IncludeTotalCosts : AbstractIndexCreationTask<MPDocument, HomeBlurb_IncludeTotalCosts.ReduceResult>
{
public class ReduceResult
{
public string Name { get; set; }
public string Constituency { get; set; }
public decimal AmountPaid { get; set; }
}
public HomeBlurb_IncludeTotalCosts()
{
Map = mps => from mp in mps
from expense in mp.Expenses
select new
{
mp.Name,
mp.Constituency,
AmountPaid = expense.AmountPaid ?? 0M
};
Reduce = results => from result in results
group result by new { result.Name, result.Constituency }
into g
select new
{
g.Key.Name,
g.Key.Constituency,
AmountPaid = g.Sum(x => x.AmountPaid)
};
}
}
The index is created by Raven (looking at it through Raven Studio) and appears to be fine.
The thing that really throws me is that the documents I'm using do not contain any doubles or ints, the only numbers I am storing are decimals.
What might be causing the problem?
The problem is in this line:
Replace this with: