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

Inspecting property maps for validation and copying of metadata

Đang mở
#721 0 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ó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu bằng việc xem xét cơ chế kiểm tra metadata mapping ở mức thấp hơn của thư viện và cách cơ chế này cung cấp các thuộc tính nguồn và đích. Điều tra xem các mapping có thể được đối chiếu với dbContext.Model của EF Core cho các mapping trực tiếp và ngược hay không. Được xem là hoàn tất khi có câu trả lời rõ ràng về tính khả thi hoặc một API được xác định để truy xuất metadata thuộc tính liên quan.

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

Mô tả

feature request ProjectToType features

My problem is that I want to be able to propagate metadata managed by EF Core (for example, MaxLength which can be looked up through IModel) all the way to the frontend, including DTO validation (I mean adding metadata to properties, just like DataAnnotations, but automatically), and up until the swagger schema. I haven't seen anyone ever do this in a project, but it feels like the only right way to go about this.

This should be in fact pretty easy to implement, given the mapping library offers a way to inspect the mapping metadata at a lower level. Basically, in the simplest case, you need to look at what property in the entity a given property of the dto maps to, and then query its metadata via dbContext.Model, then apply this metadata to the corresponding property of the DTO in some way (that's really less important).

I know there are cases when the properties are not mapped one-to-one, but the thing I described will cover 99% of cases. The things that don't map directly (two properties could be concatenated, or an int might end up as a string) can be validated after the mapping of the dto to the entity, and the errors reported via a backwards map (by looking up which properties the property of the entity was mapped from). This kind of advanced errors isn't expressible in either swagger or data annotations anyway.

So, my question is, does this library offer the sort of metadata mapping that could help one implement this? I mean looking up which property a given property maps to, and looking up which set of properties a property maps from if it's not mapped directly.

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.