Inverse of `.MapTo<'T>`
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comienza revisando el uso existente de MapTo<'T'> y el flujo Create/SubmitUpdates mostrado en el issue. Determina la API y el comportamiento de mapeo necesarios para convertir un registro en una entidad, incluido cómo debería funcionar el ejemplo sin asignaciones por columna; se considera terminado cuando el comportamiento y los casos compatibles estén definidos y verificados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- F#
- Estrellas
- 627
- Forks
- 147
- Merge medio
- 2 h 2 min
- PR fusionados (30 d)
- 1
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de fsprojects/SQLProvider
-
enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
fsprojects/SQLProvider#872 · 2 comentarios ·
-
Repo Assist? Abiertoenhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
fsprojects/SQLProvider#870 · 1 comentario ·
-
postgresql
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
fsprojects/SQLProvider#869 · 2 comentarios ·
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 42/100
fsprojects/SQLProvider#868 · 2 comentarios ·
-
sql server
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
fsprojects/SQLProvider#851 · 1 comentario ·
Todos los issues de fsprojects/SQLProvider
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
AstrBotDevs/AstrBot#10205 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
OHDSI/Data2Evidence#3394 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100