Walya.Sql 0.1.1

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Walya.Sql --version 0.1.1
                    
NuGet\Install-Package Walya.Sql -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Walya.Sql" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Walya.Sql" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Walya.Sql" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Walya.Sql --version 0.1.1
                    
#r "nuget: Walya.Sql, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Walya.Sql@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Walya.Sql&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Walya.Sql&version=0.1.1
                    
Install as a Cake Tool

Walya

Walya is a .NET-first expression language and runtime that lets you embed concise, functional business logic inside your applications. It ships with a parser, evaluator, formatter, CLI, unit tests, and optional SQL/GIS helpers, making it straightforward to evaluate custom scripts, map data, or compute derived values at runtime.

Highlights

  • Expression-oriented language with blocks, lambdas, pattern-like switches, string templates, lists, and key-value collections.
  • Batteries-included standard library covering math, logic, text, list processing, OS helpers, HTML utilities, and JSON conversion.
  • Ergonomic .NET embedding via Walya.Engine.Evaluate(...), strongly-typed error reporting, and deterministic formatting utilities.
  • Extensible through custom IFsFunction implementations or ad-hoc variables injected with DefaultFsDataProvider.
  • Extra packages for SQL Server and NetTopologySuite geometries, plus an experimental JavaScript interpreter port.

Repository Layout

  • Walya/ - core library targeting .NET 6.0; contains the parser, runtime, standard library, and data model.
  • Walya.Cli/ - minimal .NET 8 CLI (walyacli) that evaluates expressions from the command line.
  • Walya.Example/ - interactive console sample that demonstrates the REPL-style usage of the runtime.
  • Walya.Sql/ - optional extension with SQL/geometry helpers and type normalization for ADO.NET results.
  • Walya.Test/ - NUnit-based test suite covering parsing, evaluation, errors, and formatting.
  • js-port/ - in-progress JavaScript port plus editor experiments and examples.

Quick Start

Prerequisites

Install the .NET 8 SDK (includes the .NET 6 tooling required by the library projects).

Build Everything

dotnet restore Walya.sln
dotnet build Walya.sln

Try the CLI

# Evaluate a simple expression
dotnet run --project Walya.Cli -- "(2 + 3) * 4"

# Evaluate a block with variables and built-in helpers
dotnet run --project Walya.Cli -- "{ rate:0.13; net:(gross)=>gross*(1-rate); return net(12500); }"

Embed in Your Application

using System;
using System.Collections.Generic;
using Walya;
using Walya.Model;

var globals = new DefaultFsDataProvider(new List<KeyValuePair<string, object>>
{
    new KeyValuePair<string, object>("taxRate", 0.15),
    new KeyValuePair<string, object>("format", (Func<object,string>)(value => string.Format("{0:#,#0.00}", value)))
});

var expression = "{ net:(gross)=>gross*(1-taxRate); return format(net(gross)); }";
var context = new ObjectKvc(new { gross = 5200 });
var result = Walya.Engine.Evaluate(new KvcProvider(context, globals), expression);

var output = new StringBuilder();
Walya.Engine.Format(output, result);
Console.WriteLine(output);

The runtime normalizes .NET values so that primitive types, lists, key-value collections, GUIDs, byte arrays, and even delegates translate seamlessly to script data.

Language at a Glance

Script files are case-insensitive and expression-oriented. Common constructs include:

  • Blocks: { items:[1,2,3]; return Sum(items); }
  • Lambdas: (x)=>x*x or (row, index)=>{ ... }
  • String templates: f"Hello {name}!"
  • Collections: Lists [1, 2, 3] and records {name:"Ada", skills:["math","logic"]}
  • Control: If, Switch, Case, fault for structured errors
  • Functions: Map, Reduce, Filter, Distinct, Take, JoinText, Format, TicksToDate, point, and many more

A more elaborate example lives in Walya/TestFormula.text, where a payroll table is generated via mapping and HTML string templates.

Extending the Runtime

Custom functions are regular .NET classes implementing IFsFunction:

public class HexFunction : IFsFunction
{
    public string Symbol => "hex";
    public int MaxParsCount => 1;
    public CallType CallType => CallType.Prefix;
    public int Precedence => 0;

    public object Evaluate(IFsDataProvider context, IParameterList parameters)
    {
        var value = Convert.ToInt64(parameters.GetParameter(context, 0));
        return $"0x{value:X}";
    }

    public string ParName(int index) => "value";
}

Create a parameterless constructor, reference the assembly, and DefaultFsDataProvider.LoadFromAssembly(...) will auto-register the symbol (including optional aliases via FunctionAliasAttribute).

SQL & GIS Helpers

Walya.Sql adds converters for Sql* types and NetTopologySuite geometries plus GIS helpers such as point(x, y). Reference the project alongside the core library to normalize database values before exposing them to scripts.

JavaScript Port (Experimental)

The js-port/ folder contains a progressively feature-complete JavaScript interpreter that mirrors the .NET runtime. See js-port/AGENTS.md and js-port/port-progress.md for implementation notes and status.

Testing

Run the NUnit suite to ensure language changes remain backwards compatible:

dotnet test Walya.sln

Contributing

Issues and pull requests are welcome. If you plan substantial language or runtime changes, open an issue first so we can align on approach.

Maintainers

License

Released under the MIT License. See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated

Initial companion package for database scenarios.