"IgnoreIf" doesn't work for records
还没有人认领这个 Issue。
评估
调研方向
首先,在 Mapster 10.0.11 中重现报告的 mapper 代码片段,并将生成的表达式与版本 7 进行比较。重点关注 records 的 IgnoreIf 处理,并通过回归测试验证修复,测试应表明生成的 mapping 遵循 key 检查,并在 key 缺失时保持 BoxPost 不变。
由索引模型根据 Issue 内容生成。
描述
Hi. In version 10.0.11, "IgnoreIf" doesn't work as it did in version 7... My mapper is written like this:
.Map(ask => ask.BoxPost, crm => crm.GetValue<AddressEntity, string?>(nameof(AddressEntity.BoxPost)))
.IgnoreIf((d, ask) => !d.ContainsKey<AddressEntity>(nameof(AddressEntity.BoxPost)), nameof(AddressEntity.BoxPost))
previously, in version 7, the following mapper code was generated:
.If (
.Call ReForm.Ism.Core.Serialization.Extensions.JsonObjectExtension.ContainsKey(
$var1,
"BoxPost")
) {
.Block() {
$result.BoxPost = .Invoke (.Lambda #Lambda2<System.Func`3[System.String,System.Nullable`1[System.Decimal],System.Nullable`1[System.Decimal]]>)(
.Call ReForm.Ism.Core.Serialization.Extensions.JsonObjectExtension.GetValue(
$var1,
"BoxPost"),
$result.BoxPost)
}
} .Else {
.Default(System.Void)
};
and now I get this:
BoxPost = .Invoke (.Lambda #Lambda2<System.Func`2[System.String,System.Nullable`1[System.Decimal]]>)(.Call ReForm.Ism.Core.Serialization.Extensions.JsonObjectExtension.GetValue(
$var1,
"BoxPost")),
It turns out that the presence of "IgnoreIf" does not change anything.
- 主要语言
- C#
- 星标
- 5.2k
- 派生
- 409
- 平均合并
- 3 天 4 小时
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
MapsterMapper/Mapster 的其他 Issue
-
.NET Matrix未关闭
难度 2/5 1-3 小时 新手友好度 72/100
MapsterMapper/Mapster#1003 ·
-
难度 3/5 1-2 天 新手友好度 58/100
MapsterMapper/Mapster#1024 · 1 条评论 ·
-
[Mapster Tool] Add support for global:: to disambiguate type names in generated mappers可能已有人在做 @DocSvartz 于 1 天前认领。 未关闭improvement
难度 3/5 1-2 天 新手友好度 65/100
MapsterMapper/Mapster#1020 · 3 条评论 ·
-
Mapster.Tool - PropertySettingBuilder.Map(member, mapFunc, targetPropertyName) method is not working as expected!可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
MapsterMapper/Mapster#1017 · 6 条评论 ·
-
难度 3/5 1-2 天 新手友好度 55/100
MapsterMapper/Mapster#1005 ·
查看 MapsterMapper/Mapster 的全部 Issue
相似的 Issue
-
needs-triage
难度 2/5 1-3 小时 新手友好度 78/100
elsa-workflows/elsa-foundation#3130 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
KnifeLemon/Filee#294 ·
维护者通常 1 天内回复
-
good first issue
难度 1/5 1-3 小时 新手友好度 88/100
GlebKievsky/git-tips#4 ·
-
难度 1/5 1 小时以内 新手友好度 77/100
OrchardCMS/OrchardCore#20088 · 1 条评论 ·
维护者通常 1 天内回复