Inverse of `.MapTo<'T>`
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
調査の方向性
まず、既存の MapTo<'T'> の使用方法と、issue に示されている Create/SubmitUpdates のフローを確認します。レコードをエンティティに変換するために必要な API とマッピング動作を特定します。これには、列ごとの割り当てなしで例がどのように動作すべきかも含まれます。動作とサポート対象のケースが定義され、検証されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- F#
- スター
- 627
- フォーク
- 147
- 平均マージ
- 2時間 2分
- マージ済み PR(30日)
- 1
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fsprojects/SQLProvider のほかの issue
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
fsprojects/SQLProvider#872 · コメント 2 件 ·
-
Repo Assist? オープンenhancement
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
fsprojects/SQLProvider#870 · コメント 1 件 ·
-
postgresql
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
fsprojects/SQLProvider#869 · コメント 2 件 ·
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 42/100
fsprojects/SQLProvider#868 · コメント 2 件 ·
-
sql server
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
fsprojects/SQLProvider#851 · コメント 1 件 ·
fsprojects/SQLProvider の issue をすべて見る
似ている issue
-
Edit: CW+ オープンchannels:edit check:passed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
Area/ICP Type/Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
wso2/product-integrator#2514 ·
-
[6.x]: "Cannot use object of type stdClass as array" loading Users index (regression of #19182) オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
community-scripts/ProxmoxVE#17396 · コメント 1 件 ·
-
bug possible-duplicate
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
AOSSIE-Org/PictoPy#1553 · コメント 4 件 ·