Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Exception occured when map single object from EF Core entity class (with proxy)

Đang mở
#1,024 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
backend

Hướng nghiên cứu

Start by tracing how Mapster resolves the runtime source type in Adapt<CreateApiRequest>(), comparing it with the explicit-source-type overload that succeeds. Reproduce the failure with an EF Core lazy-loading proxy and check the existing mapping tests for proxy or derived types. Done when mapping the proxy without an explicit source type succeeds while the destination-member validation remains correct.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hi, i'm using Mapster ver. 10.0.11, i got exception when doing single object mapping
The following members of destination class CreateApiRequest do not have a corresponding source member mapped or ignored: ...
which i have include described field in mapster config and passed TypeAdapterConfig.GlobalSettings.Compile();.

My code when call adapt:
var entity = getEntityById(id); //EF Core entity
var mapped = entity.Adapt<CreateApiRequest>(); //map with mapster, got exception here, compile is ok

As i investigated, it turns out that entity type is Proxy rather than actual type (i'm using EF LazyLoadingProxies).
Current workaround that i'm using is to specify source type when mapping:
var mapped = entity.Adapt<EntityType, CreateApiRequest>(); //this line successfully run

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của MapsterMapper/Mapster

Tất cả issue của MapsterMapper/Mapster

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.