First cut of field order by function

This commit is contained in:
Daniel J. Summers 2024-08-13 09:03:05 -04:00
parent 96f5e1515d
commit edd4d006da
2 changed files with 16 additions and 4 deletions

View File

@ -292,3 +292,15 @@ module Query =
[<System.Obsolete "Use Find instead">] [<System.Obsolete "Use Find instead">]
let selectFromTable tableName = let selectFromTable tableName =
find tableName find tableName
/// Create an ORDER BY clause for the given fields
[<CompiledName "OrderBy">]
let orderBy fields dialect =
if Seq.isEmpty fields then ""
else
fields
|> Seq.map (fun it ->
let direction = if it.Name.Contains ' ' then $" {(it.Name.Split ' ')[1]}" else ""
it.Path dialect + direction)
|> String.concat ", "
|> function it -> $" ORDER BY {it}"

View File

@ -3,10 +3,10 @@
<TargetFrameworks>net6.0;net8.0</TargetFrameworks> <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<DebugType>embedded</DebugType> <DebugType>embedded</DebugType>
<GenerateDocumentationFile>false</GenerateDocumentationFile> <GenerateDocumentationFile>false</GenerateDocumentationFile>
<AssemblyVersion>3.1.0.0</AssemblyVersion> <AssemblyVersion>4.0.0.0</AssemblyVersion>
<FileVersion>3.1.0.0</FileVersion> <FileVersion>4.0.0.0</FileVersion>
<VersionPrefix>3.1.0</VersionPrefix> <VersionPrefix>4.0.0</VersionPrefix>
<PackageReleaseNotes>Add BT (between) operator; drop .NET 7 support</PackageReleaseNotes> <PackageReleaseNotes>Change ByField to ByFields; support dot-access to document fields; add Find*Ordered functions/methods</PackageReleaseNotes>
<Authors>danieljsummers</Authors> <Authors>danieljsummers</Authors>
<Company>Bit Badger Solutions</Company> <Company>Bit Badger Solutions</Company>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>