Discriminated Unions for Static Data
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
The issue names no files or tests; start by reading the existing Individuals feature and the query/type-provider paths it relies on. Compare those entry points with the manual ContentTypeId projection shown here; done means discriminated-union foreign-key IDs can be used directly without that mapping.
Written by the indexing model from the issue text.
Description
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?
- Dominant language
- F#
- Stars
- 627
- Forks
- 147
- Avg merge
- 2h 2m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fsprojects/SQLProvider
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 55/100
fsprojects/SQLProvider#872 · 2 comments ·
-
Repo Assist? Openenhancement
Difficulty 5/5 Over a week Newbie friendliness 10/100
fsprojects/SQLProvider#870 · 1 comment ·
-
postgresql
Difficulty 4/5 3-5 days Newbie friendliness 58/100
fsprojects/SQLProvider#869 · 2 comments ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
fsprojects/SQLProvider#868 · 2 comments ·
-
sql server
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fsprojects/SQLProvider#851 · 1 comment ·
All issues in fsprojects/SQLProvider
Similar issues
-
[6.x]: "Cannot use object of type stdClass as array" loading Users index (regression of #19182) Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
community-scripts/ProxmoxVE#17396 · 1 comment ·
-
bug possible-duplicate
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
AOSSIE-Org/PictoPy#1553 · 4 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
BasedHardware/omi#15274 · 3 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100