Dzoukr / Dapper.FSharp

Lightweight F# extension for StackOverflow Dapper with support for MSSQL, MySQL, PostgreSQL, and SQLite
MIT License
365 stars 35 forks source link

Support union/union all cases #101

Closed stanislav-poliakov closed 6 months ago

stanislav-poliakov commented 6 months ago

It will be great have possibility to use it

for p in personTable do
where (p.Position > 5)
unionAll
for p in personTable do
p.Position < 10)
for p in personTable do
where (p.Position > 5)
distinctUnion //or just `union`
for p in personTable do
p.Position < 10)
Dzoukr commented 6 months ago

Currently, there is no support for having two selects in one query 🤔 ... but it should be possible in theory...

JordanMarr commented 6 months ago

It might require something like this:

let positionLt10 = 
    select { 
        for p in personTable do
        where (p.Position < 10)
    }

select {
    for p in personTable do
    where (p.Position > 5)
    unionAll positionLt10
}
 |> conn.SelectAsync<Person>

OTOH, that's kind of clunky, so I'm inclined to think that this is one of those "write a manual query" situations.

Dzoukr commented 6 months ago

OTOH, that's kind of clunky, so I'm inclined to think that this is one of those "write a manual query" situations.

Same here. Let's keep the API nice and clean.