Skip to content

πŸš€ First Implementation

Fadhly Permata edited this page Mar 21, 2026 · 4 revisions

Ready to write your very first query with JQL.Net? It's as easy as ordering pizza! πŸ• Whether you're a C# wizard, a VB.NET veteran, or an F# enthusiast, we've got a seat for you at the table. 🌟

JQL.Net supports two main ways to execute your queries. Let's check them out!


πŸ“„ Our Sample Data

We'll use this transaction list for all our examples. Notice our lead developer, Fadhly Permata, is right at the top! πŸ‘¨β€πŸ’»

[
  { "Id": 1, "CustomerName": "Fadhly Permata", "Category": "Elektronik", "Amount": 5000000 },
  { "Id": 2, "CustomerName": "Budi Santoso", "Category": "Elektronik", "Amount": 1500000 },
  { "Id": 3, "CustomerName": "Sari Wijaya", "Category": "Pakaian", "Amount": 200000 },
  { "Id": 4, "CustomerName": "Andi Pratama", "Category": "Elektronik", "Amount": 3000000 }
]

πŸ”· C# Implementation 🎸

using JQL.Net;
using JQL.Net.Core;
using JQL.Net.Exceptions;

// --- Method 1: Object-Oriented Approach ---
try {
    var request = new JsonQueryRequest { 
        Select = "CustomerName, Amount", 
        From = jsonInput 
    };
    var result = JsonQueryEngine.Execute(request);
} catch (JsonQueryException ex) {
    // Handle query-specific errors
    Console.WriteLine($"Error: {ex.Message}");
}

// --- Method 2: SQL String Approach (The .Parse() Way) ---
try {
    var payload = new JsonQueryRequest {
        RawQuery = "SELECT t.CustomerName FROM $.Transactions AS t WHERE t.CustomerName == 'Fadhly Permata'",
        Data = myDataObject
    };
    var result = JsonQueryEngine.Execute(request: payload.Parse());
} catch (JsonQueryException ex) {
    // Handling error using JsonQueryException
    Console.WriteLine($"Error: {ex.Message}");
}

πŸ”· VB.NET Implementation β˜•

Imports JQL.Net
Imports JQL.Net.Core
Imports JQL.Net.Exceptions

' --- Method 1: Object-Oriented Approach ---
Try
    Dim request As New JsonQueryRequest With {
        .Select = "CustomerName, Amount",
        .From = jsonInput
    }
    Dim result = JsonQueryEngine.Execute(request)
Catch ex As JsonQueryException
    Console.WriteLine($"Error: {ex.Message}")
End Try

' --- Method 2: SQL String Approach (.Parse) ---
Try
    Dim payload As New JsonQueryRequest With {
        .RawQuery = "SELECT t.CustomerName FROM $.Transactions AS t WHERE t.CustomerName == 'Fadhly Permata'",
        .Data = myDataObject
    }
    Dim result = JsonQueryEngine.Execute(request:=payload.Parse())
Catch ex As JsonQueryException
    Console.WriteLine($"Error: {ex.Message}")
End Try

πŸ”· F# Implementation πŸ§ͺ

open JQL.Net
open JQL.Net.Core
open JQL.Net.Exceptions

// --- Method 1: Object-Oriented Approach ---
try
    let request = JsonQueryRequest(Select = "CustomerName", From = jsonInput)
    let result = JsonQueryEngine.Execute(request)
    ()
with
| :? JsonQueryException as ex -> printfn "Error: %s" ex.Message

// --- Method 2: SQL String Approach (.Parse) ---
try
    let payload = JsonQueryRequest(RawQuery = "SELECT t.CustomerName FROM $.Transactions AS t WHERE t.CustomerName == 'Fadhly Permata'", Data = myData)
    let result = JsonQueryEngine.Execute(request = payload.Parse())
    ()
with
| :? JsonQueryException as ex -> printfn "Error: %s" ex.Message

πŸ’‘ Which one should I choose?

  • Object-Oriented: Best for static queries where you want full control over each property.
  • SQL String: Perfect for dynamic queries, user-inputted strings, or if you just love the feel of pure SQL! πŸͺ„

🧭 What's Next?

Ready to give your output fields some custom names? It's time to learn about Aliases!

πŸ‘‰ Jump into Query with Alias to keep the momentum going!


Questions? Feedback? Open an Issue and let's chat!

πŸ“– Documentation

πŸš€ Implementation Samples


πŸ› οΈ More Resources

Clone this wiki locally