3 ms·
You should show the definition of 'foo'. That's where things get ugly.
by boris 12y ago
You should show the definition of 'foo'. That's where things get ugly.
- enricosada 12y agothings usually get ugly with projection (one class = one select) or class reuse (mapping) this is code -> sql string -> exec -> code (mapping results) best approach (ihmo) is using: sql string -> exec -> results with type for input/output directly generated sql string (and check for types) like F# sql type provider ( http://fsprojects.github.io/FSharp.Data.SqlClient/ http://fsprojects.github.io/FSharp.Data.SqlClient/ ) [<Literal>] let query = " SELECT TOP(@TopN) FirstName, LastName, SalesYTD FROM Sales.vSalesPerson WHERE CountryRegionName = @regionName AND SalesYTD > @salesMoreThan ORDER BY SalesYTD " type SalesPersonQuery = SqlCommandProvider<query, connectionString> let cmd = new SalesPersonQuery() cmd.AsyncExecute(TopN = 3L, regionName = "United States", salesMoreThan = 1000000M) |> Async.RunSynchronously //output //seq // [("Pamela", "Ansman-Wolfe", 1352577.1325M); // ("David", "Campbell", 1573012.9383M); // ("Tete", "Mensa-Annan", 1576562.1966M)] everything typed, but: - without the need to define class for input / output - without learn a new functions - easy add database specific syntax