Ravendb 索引 JSON 参考问题

问题描述

我们最近从 Raven DB 3.5.9 迁移到 5.1.2。我们有包含文档的集合字段,例如

{
    "$id": "1","FieldName": "FName","Rules": [
        {
            "$id": "2","VariantId": "0ad608a6-d489-4e73-b5de-63803fae7ad5","CoveredPlanTypes": [
                "ABC","DEF"
            ]
            "Formatters": [],"Transformations": [
                {
                    "$id": "3","ConditionExpression": {
                        "$id": "4","SubType": "ConditionCombination","Name": "AND","Type": "ConditionComputation"
                    },"Variants": {
                        "$id": "20"
                    }
                },{
                    "$id": "21","ConditionExpression": {
                        "$id": "22","Variants": {
                        "$id": "41"
                    }
                }
            ]
        },{
            "$id": "557","VariantId": "8299a037-2e38-4480-bad9-cf9137786876","CoveredPlanTypes": [
                "ABC"
            ],"Formatters": [],"Transformations": [
                {
                    "$ref": "3"
                },{
                    "$ref": "21"
                },{
                    "$id": "558","ConditionExpression": {
                        "$id": "559","Variants": {
                        "$id": "611"
                    }
                }
            ]
        }
    ],"CreatedOnInstant": "2020-12-16T21:58:49.2241825Z","@metadata": {
        "@collection": "Fields","Raven-Clr-Type": "Domain.Field.Field,Domain",}
}

我们有以下索引类

    public class Field_RuleVariantsByPlanType : AbstractIndexCreationTask<Field,Rule>
    {
        public Field_RuleVariantsByPlanType()
        {
            Map = fields => from field in fields
                            from ruleVariant in field.Rules
                            from planType in ruleVariant.CoveredPlanTypes.DefaultIfEmpty("")
                            select new Rule
                            {
                                Id = field.Id,FieldName = field.FieldName,CoveredPlanType = planType,Formatters = ruleVariant.Formatters,Transformations = ruleVariant.Transformations,};
            StoreAllFields(FieldStorage.Yes);
        }
}

当我们尝试执行 var rule = await _session.Query<Rule,Field_RuleVariantsByPlanType>().Where(x => x.Id == "fields/7809").ProjectInto<Rule>().ToListAsync(); 时,我们没有解析第二条规则中加载的转换的引用,它们为空,即 "Transformations": [ { "$ref": "3" },{ "$ref": "21" },好像我们检查 var rule = await _session.LoadAsync<Field>("fields/7809"); json 中的引用被解析,这次我们在第二条规则中得到了正确的 3 次转换。请帮忙

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...