Inverse of `.MapTo<'T>`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia esaminando l’uso esistente di MapTo<'T'> e il flusso Create/SubmitUpdates mostrato nell’issue. Determina l’API e il comportamento di mapping necessari per trasformare un record in un’entità, incluso il modo in cui l’esempio dovrebbe funzionare senza assegnazioni per colonna; il lavoro è completato quando il comportamento e i casi supportati sono definiti e verificati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- F#
- Stelle
- 627
- Fork
- 147
- Merge medio
- 2h 2m
- PR unite (30g)
- 1
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di fsprojects/SQLProvider
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
fsprojects/SQLProvider#872 · 2 commenti ·
-
Repo Assist? Apertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
fsprojects/SQLProvider#870 · 1 commento ·
-
postgresql
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
fsprojects/SQLProvider#869 · 2 commenti ·
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 42/100
fsprojects/SQLProvider#868 · 2 commenti ·
-
sql server
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
fsprojects/SQLProvider#851 · 1 commento ·
Tutte le issue di fsprojects/SQLProvider
Issue simili
-
[6.x]: "Cannot use object of type stdClass as array" loading Users index (regression of #19182) Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
community-scripts/ProxmoxVE#17396 · 1 commento ·
-
bug possible-duplicate
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
AOSSIE-Org/PictoPy#1553 · 4 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
BasedHardware/omi#15274 · 3 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100