Error: Could not understand expression: .OfType().GroupBy(a => a.Id) RavenDb
Error: Could not understand expression: .OfType().GroupBy(a => a.Id) RavenDb
我目前正在尝试从数据库中获取发票的正确增值税百分比。我的代码如下所示:
var lines = store.Query<DebetInvoiceItemAll.Mapping, DebetInvoiceItemAll>()
.Where(a => a.InvoiceId.Equals(invoice.Id, StringComparison.OrdinalIgnoreCase))
.As<DebetInvoiceDistributedPurchaseItem>()
.All().ToList();
value = info.Amount;
decimal totalInvoicePrice = invoice.TotalDecimal ?? 0m;
decimal percentagePaid = value / totalInvoicePrice;
var rates = store.Query<VATPercentageAll.Mapping, VATPercentageAll>()
.As<VATPercentage>()
.GroupBy(a => a.Id)
.ToDictionary(a => a.Key, a => a
.ToDictionary(b => b.CountryId, b => b.Percentage, StringComparer.OrdinalIgnoreCase));
当我尝试 运行 代码时,它在最后一行崩溃了。错误说:
Could not understand expression: .OfType().GroupBy(a => a.Id).
但是问题不在 myGroupBy 中,而是在 ToDictionary 中。有谁知道为什么会抛出这个异常?
提前致谢。
您正在尝试对 RavenDB 查询 运行 GroupBy
,但这不受支持。
如果你想做group bys,你需要使用一个map/reduce索引。
我目前正在尝试从数据库中获取发票的正确增值税百分比。我的代码如下所示:
var lines = store.Query<DebetInvoiceItemAll.Mapping, DebetInvoiceItemAll>()
.Where(a => a.InvoiceId.Equals(invoice.Id, StringComparison.OrdinalIgnoreCase))
.As<DebetInvoiceDistributedPurchaseItem>()
.All().ToList();
value = info.Amount;
decimal totalInvoicePrice = invoice.TotalDecimal ?? 0m;
decimal percentagePaid = value / totalInvoicePrice;
var rates = store.Query<VATPercentageAll.Mapping, VATPercentageAll>()
.As<VATPercentage>()
.GroupBy(a => a.Id)
.ToDictionary(a => a.Key, a => a
.ToDictionary(b => b.CountryId, b => b.Percentage, StringComparer.OrdinalIgnoreCase));
当我尝试 运行 代码时,它在最后一行崩溃了。错误说:
Could not understand expression: .OfType().GroupBy(a => a.Id).
但是问题不在 myGroupBy 中,而是在 ToDictionary 中。有谁知道为什么会抛出这个异常? 提前致谢。
您正在尝试对 RavenDB 查询 运行 GroupBy
,但这不受支持。
如果你想做group bys,你需要使用一个map/reduce索引。