Support F# OTB
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
Hello guys, thanks for the awesome job on Dapper best sql tool ever :)
I would like to talk about F# and Dapper.
Right now I have a lot of duplicate code in my projects specially because of DU and Option types.
For instance I have to write code like this for every single DU
type SkuClassificationTypeHandler() =
inherit SqlMapper.TypeHandler<SkuClassification>()
override this.Parse (value) =
match value :?> string with
| "A" -> A
| "B" -> B
| "C" -> C
| "D" -> D
| "E" -> E
| _ -> E
override this.SetValue (p, value) =
p.DbType <- DbType.String
p.Size <- 1
p.Value <-
match value with
| A -> "A"
| B -> "B"
| C -> "C"
| D -> "D"
| E -> "E"
And this for Option type
type OptionHandler<'T>() =
inherit SqlMapper.TypeHandler<option<'T>>()
override __.SetValue(param, value) =
let valueOrNull =
match value with
| Some x -> box x
| None -> null
param.Value <- valueOrNull
override __.Parse value =
if isNull value || value = (DBNull.Value :> obj)
then None
else Some (value :?> 'T)
SqlMapper.AddTypeHandler (OptionHandler<int>())
SqlMapper.AddTypeHandler (OptionHandler<string>())
SqlMapper.AddTypeHandler (OptionHandler<MyRecord>())
Is it possible to support F# specificities OTB? Maybe for 2.0?
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.
Research direction
The issue names SqlMapper.TypeHandler and SqlMapper.AddTypeHandler as the relevant entry points; start by tracing how those handlers are registered and invoked. Done would mean F# DU and Option cases are supported out of the box without the repeated per-type handlers shown, with coverage for the examples in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100