Inverse of `.MapTo<'T>`
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
Hướng nghiên cứu
Bắt đầu bằng việc xem xét cách sử dụng MapTo<'T'> hiện có và luồng Create/SubmitUpdates được nêu trong issue. Xác định API và hành vi ánh xạ cần thiết để chuyển một bản ghi thành một entity, bao gồm cả cách ví dụ này sẽ hoạt động mà không cần gán cho từng cột; được coi là hoàn tất khi hành vi và các trường hợp được hỗ trợ đã được xác định và kiểm chứng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
This library provides the .MapTo<'T> to map an entity to a record type (which is awesome), but it is not as simple to map this record type back to an entity. Mapping back can be done manually, but it can get a little cumbersome when the entity has a lot of columns.
Describe the solution you'd like
It would be cool to have some sort of inverse of the .MapTo<'T> method that could take a record and return an entity.
Describe alternatives you've considered
As mentioned above, it can currently be done manually. This works fine for small entities, but scales with the number of columns in the entity.
Basic Example
If we have a table MyTable with column Id that is mapped by the record MyTable_Row, you can easily grab a row based on the column Id using
let getById (id: int): MyTable_Row option =
let foundRow = query {
for row in ctx.Dbo.MyTable do
where (row.Id = id)
select (Some row)
exactlyOneOrDefault
}
match foundRow with
| Some foundRow -> Some( foundRow.MapTo<MyTable_Row>() )
| None -> None
This method is independent of the number of columns in MyTable (other than in the definition of MyTable_Row). But, if we want to add a row to MyTable from a MyTable_Row, we need to manually specify that each column gets populated:
let insertRow (myRow: MyTable_Row) =
let newRow = ctx.Dbo.MyTable.Create()
newRow.Id <- myRow.Id
newRow.Column1 <- myRow.Column1
newRow.Column2 <- myRow.Column2
newRow.Column3 <- myRow.Column3
newRow.Column4 <- myRow.Column4
...
newRow.ColumnN <- myRow.ColumnN
ctx.SubmitUpdates()
With this, not only does the definition of the record type need to scale with the number of columns in the entity, but all functions performing inserts must too.
- Ngôn ngữ chính
- F#
- Star
- 627
- Fork
- 147
- Merge trung bình
- 2 giờ 2 phút
- Pull request đã merge (30 ngày)
- 1
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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 fsprojects/SQLProvider
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
fsprojects/SQLProvider#872 · 2 bình luận ·
-
Repo Assist? Đang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
fsprojects/SQLProvider#870 · 1 bình luận ·
-
postgresql
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
fsprojects/SQLProvider#869 · 2 bình luận ·
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 42/100
fsprojects/SQLProvider#868 · 2 bình luận ·
-
sql server
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
fsprojects/SQLProvider#851 · 1 bình luận ·
Tất cả issue của fsprojects/SQLProvider
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
AstrBotDevs/AstrBot#10205 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
OHDSI/Data2Evidence#3394 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100