带有静态索引数组Map属性的匿名类型属性

时间:2012-10-14 16:23:00

标签: ravendb

我有一个实体如下:

public class WdiAndGdi
{
    public string CountryName { get; set; }

    public string CountryCode { get; set; }

    public string IndicatorName { get; set; }

    public string IndicatorCode { get; set; }

    public Decimal? Year1960 { get; set; }
    public Decimal? Year1961 { get; set; }

    public Decimal? Year1962 { get; set; }
    public Decimal? Year1963 { get; set; }
    public Decimal? Year1964 { get; set; }
    public Decimal? Year1965 { get; set; }
    public Decimal? Year1966 { get; set; }
    public Decimal? Year1967 { get; set; }
    public Decimal? Year1968 { get; set; }
}

并且,我想创建一个索引,如下所示(仅显示Map属性):

Map = indicators => from indicator in indicators
                            select new
                                       {
                                           indicator.CountryName,
                                           indicator.IndicatorName,
                                           Statistics = new[] { indicator.Year1960, indicator.Year1961,... },
                                           Min = 0.0m,
                                           Max = 0.0m,
                                           DataPresentForYears = 0
                                       };

但是,当我尝试执行此索引时,出现以下错误:

{
"Url": "/indexes/IndexByIndicator",
 "Error": "System.InvalidOperationException: Could not understand query: \r\n-- line 2       col139: invalid NewExpression\r\n-- line 2 col 179: Can't parse double .0.0 at .....

以下是请求的提琴手跟踪:

{"Name":null,"Map":"docs.WdiAndGdis\r\n\t.Select(indicator => new {CountryName =     indicator.CountryName, IndicatorName = indicator.IndicatorName, Statistics = new  System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral,   PublicKeyToken=b77a5c561934e089]] []{((decimal?)indicator.Year1960), ((decimal?)indicator.Year1961)}, Min = 0.0M, Max = 0.0M, DataPresentForYears = 0})","Maps":["docs.WdiAndGdis\r\n\t.Select(indicator => new {CountryName = indicator.CountryName, IndicatorName = indicator.IndicatorName, Statistics = new System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] []{((decimal?)indicator.Year1960), ((decimal?)indicator.Year1961)}, Min = 0.0M, Max = 0.0M, DataPresentForYears = 0})"],"Reduce":"results\r\n\t.GroupBy(result => new {CountryName = result.CountryName, IndicatorName = result.IndicatorName})\r\n\t.Select(g => new {Country = g.Key.CountryName, IndicatorName = g.Key.IndicatorName, Max = Enumerable.Max(g, x => ((System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][])(x.Statistics))), Min = Enumerable.Min(g, x => ((System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][])(x.Statistics))), DataPresentForYears = g\r\n\t.SelectMany(x => x.Statistics).Count(s => s.HasValue)})","TransformResults":null,"IsMapReduce":true,"IsCompiled":false,"IsTemp":false,"Stores":{},"Indexes":{},"SortOptions":{},"Analyzers":{},"Fields":[],"Type":"MapReduce"}

0 个答案:

没有答案