刚刚学习 Map/Reduce,我错过了一个步骤。我读过这篇文章(使用 .NET 客户端的 RavenDB Map-Reduce 示例 https://stackoverflow.com/questions/4253334/ravendb-map-reduce-example-using-net-client)但无法完全跳转到我需要的内容。
我有一个对象:
public class User : IIdentifiable
{
public User(string username)
{
Id = String.Format(@"users/{0}", username);
Favorites = new List<string>();
}
public IList<string> Favorites { get; protected set; }
public string Id { get; set; }
}
我想要做的是获取所有用户的映射/减少收藏夹属性。像这样的东西(但这显然不起作用):
Map = users => from user in users
from oil in user.Favorites
select new { OilId = oil, Count = 1 };
Reduce = results => from result in results
group result by result.OilId into g
select new { OilId = g.Key, Count = g.Sum(x => x.Count) };
例如,如果用户 1 有收藏夹 1、2、3,用户 2 有收藏夹 1,2,则应返回 {{OilId=3, Count =1}, {OilId=2, Count = 2}, {OilId= 1,计数 = 2}}
当前代码产生异常:System.NotSupportedException:不支持节点:调用
我感觉我已经很接近了。有什么帮助吗?