Polymorphic mapping with collections maps only base class properties
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với reproducer trong issue #793 và so sánh kết quả Adapt cho một phần tử đơn với kết quả Adapt<BaseDto[]> cho collection, bao gồm cả cấu hình Include tùy chọn. Được xem là hoàn thành khi việc ánh xạ collection giữ lại ExtraProperty và OtherExtraProperty cho các kiểu runtime dẫn xuất mà không yêu cầu cấu hình tường minh đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This might be related to #776. I have a class hierarchy and a base class DTO that combines all possible properties. When mapping a single item cast to the base class - derived properties are mapped, however, when mapping a collection of the base class items - derived properties are ignored. This doesn't seem like a consistent behavior to me and now it must be fixed with explicit map config.
var items = new List<Base>
{
new DerivedOne
{
Id = Guid.NewGuid(),
ExtraProperty = "A",
Property = "a",
},
new DerivedTwo
{
Id = Guid.NewGuid(),
Property = "b",
OtherExtraProperty = "B",
}
};
// TypeAdapterConfig<Base, BaseDto>.NewConfig()
// .Include<DerivedOne, BaseDto>()
// .Include<DerivedTwo, BaseDto>();
// Here ExtraProperty and OtherExtraProperty are not mapped unless the config above is present
var mappedResultOne= b.Adapt<BaseDto[]>();
// Here OtherExtraProperty is mapped.
var mappedResultTwo = b[1].Adapt<BaseDto>();
public abstract class Base
{
public Guid Id { get; set; }
public required string Property { get; set; }
public abstract string Type { get; protected set; }
}
public class DerivedOne : Base
{
public required string ExtraProperty { get; set; }
public override string Type { get; protected set; } = "DerivedOne";
}
public class DerivedTwo : Base
{
public required string OtherExtraProperty { get; set; }
public override string Type { get; protected set; } = "DerivedTwo";
}
public record BaseDto
{
public Guid Id { get; init; }
public required string Property { get; init; }
public string? ExtraProperty { get; init; }
public string? OtherExtraProperty { get; init; }
public required string Type { get; init; }
}
- Ngôn ngữ chính
- C#
- Star
- 5.2k
- Fork
- 409
- Merge trung bình
- 3 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MapsterMapper/Mapster
-
.NET MatrixĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
MapsterMapper/Mapster#1003 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
MapsterMapper/Mapster#1024 · 1 bình luận ·
-
[Mapster Tool] Add support for global:: to disambiguate type names in generated mappersCó thể đã có người làm @DocSvartz đã nhận 1 ngày trước. Đang mởimprovement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
MapsterMapper/Mapster#1020 · 3 bình luận ·
-
Mapster.Tool - PropertySettingBuilder.Map(member, mapFunc, targetPropertyName) method is not working as expected!Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
MapsterMapper/Mapster#1017 · 6 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
MapsterMapper/Mapster#1007 · 5 bình luận ·
Tất cả issue của MapsterMapper/Mapster
Issue tương tự
-
area-TableView bug needs-triage team-Controls
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
microsoft/microsoft-ui-xaml#12351 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
AudioClient and ImageClient file path overloads send the full local path as the multipart file nameCó thể đã có người làm @sebxt đã nhận hôm nay. Đang mởarea: audio area: images feature-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
openai/openai-dotnet#1453 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
elsa-workflows/elsa-foundation#3130 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
遥测历史查询始终返回 HTTP 400,页面静默无结果Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100