Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Discriminated Unions for Static Data

オープン
#392 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
fsharp, sql
領域
databases

調査の方向性

issue ではファイルやテストが指定されていないため、まず既存の Individuals 機能と、それが依存する query/type-provider のパスを読みます。これらのエントリポイントを、ここで示されている手動の ContentTypeId projection と比較します。完了の条件は、discriminated-union foreign-key IDs をそのマッピングなしで直接使用できることです。

索引モデルが issue の本文から書いたものです。

説明

enhancement

Another question, but are there any plans for allowing discriminated unions to be used as the type for foreign key IDs to static data? I know entity framework supports this with enums but it would be handy to be able to use discriminated unions for obvious reasons:

type ContentTypeId =
  | Book
  | Magazine
  | Newspaper

...

let printData item =
  match item.ContentTypeId with
  | Book -> printfn "Found a book with id: %d" item.Id
  | Magazine -> printfn "Found a magazine with id: %d" item.Id
  | Newspaper -> printfn "Found a newspaper with id: %d" item.Id

It's possible to do this now by mapping the ID when projecting results:

let getContentTypeId = function
  | 1 -> Book
  | 2 -> Magazine
  | 3 -> Newpaper

...

query {
  for item in ctx.Dbo.Media do
  select
    { contentTypeId = getContentTypeId item.contentTypeId;
    }
}

This can get tedious and is pretty brittle, and an auto-generated solution would be preferable if possible. The infrastructure for the Individuals feature would probably be reusable to accomplish this?

主要言語
F#
スター
627
フォーク
147
平均マージ
2時間 2分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fsprojects/SQLProvider のほかの issue

fsprojects/SQLProvider の issue をすべて見る

似ている issue

Databases の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。