Skip to content

v2.4.1

Compare
Choose a tag to compare
@JordanMarr JordanMarr released this 23 Apr 17:13
· 20 commits to main since this release

SqlHydra.Query

  • Added implicit conversions to ContextType.

The ContextType (Shared, Create, CreateAsync and CreateTask) is now implicitly converted.
This allows you to either pass in a QueryContext or a function that returns a QueryContext to your selectTask and selectAsync expressions. This is a huge quality-of-life improvement, IMO!

See Select Builders in readme for more examples.

Old:

let getErrorNumbers () =
    selectAsync HydraReader.Read (Create openContext) {
        for e in dbo.ErrorLog do
        select e.ErrorNumber
    }

Becomes:

let getErrorNumbers () =
    selectAsync HydraReader.Read openContext {
        for e in dbo.ErrorLog do
        select e.ErrorNumber
    }

Old:

let getErrorNumbers (ctx: QueryContext) =
    selectAsync HydraReader.Read (Shared ctx) {
        for e in dbo.ErrorLog do
        select e.ErrorNumber
    }

Becomes:

let getErrorNumbers (ctx: QueryContext) =
    selectAsync HydraReader.Read ctx {
        for e in dbo.ErrorLog do
        select e.ErrorNumber
    }

If you create a shortcut select CE that embeds the generated HydraReader.Read function, it becomes even more succinct:

let selectTask' ct = selectTask HydraReader.Read ct

let distinctCustomerNames (ctx: QueryContext) = 
    selectTask' ctx {
        for c in SalesLT.Customer do
        select (c.FirstName, c.LastName)
        distinct
    }