JQLBuilder 1.0.60-rc.48b70041a5d29a1b442488db599a11c4df1fc057

Additional Details

Released for development purposes.

This is a prerelease version of JQLBuilder.
There is a newer version of this package available.
See the version list below for details.
dotnet add package JQLBuilder --version 1.0.60-rc.48b70041a5d29a1b442488db599a11c4df1fc057
NuGet\Install-Package JQLBuilder -Version 1.0.60-rc.48b70041a5d29a1b442488db599a11c4df1fc057
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="JQLBuilder" Version="1.0.60-rc.48b70041a5d29a1b442488db599a11c4df1fc057" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JQLBuilder --version 1.0.60-rc.48b70041a5d29a1b442488db599a11c4df1fc057
#r "nuget: JQLBuilder, 1.0.60-rc.48b70041a5d29a1b442488db599a11c4df1fc057"
#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.
// Install JQLBuilder as a Cake Addin
#addin nuget:?package=JQLBuilder&version=1.0.60-rc.48b70041a5d29a1b442488db599a11c4df1fc057&prerelease

// Install JQLBuilder as a Cake Tool
#tool nuget:?package=JQLBuilder&version=1.0.60-rc.48b70041a5d29a1b442488db599a11c4df1fc057&prerelease

JQL Builder

Build Tests Publish NuGet version (JQLBuilder)

This repository houses a C# library designed to provide a JQL (Jira Query Language) builder, aiding programmers in constructing JQL queries programmatically.

NOTE: At its current stage, the package is considered alpha, implementing only partial functionality for the Project and Version fields.

However, the library's structure is well-defined. While a comprehensive readme is currently deemed excessive, here are some examples demonstrating how the library is intended to be used, with a focus on operators and query production.

Introduction

The JqlBuilder library provides a fluent interface for constructing Jira Query Language (JQL) queries in a flexible and expressive manner. This README serves as a guide to help you understand how to use the library effectively.

Getting Started

To start building JQL queries, use the JqlBuilder.Query entry point. The library follows a fluent API design, allowing you to chain methods to construct complex queries.

JqlBuilder.Query
    .Where(f => f.Project == "example")
    .And(f => f.Assignee == "john.doe")
    .OrderBy(f => f.Project)
    .ThenByDescending(f => f.Priority)
    .ToString();

Query Construction

The library provides extension methods for constructing various parts of a JQL query:

Filtering

  • Where: Start the query with a filter condition.
  • And: Add an AND condition to the existing filter.
  • Or: Add an OR condition to the existing filter.
JqlBuilder.Query
    .Where(f => f.Project == "example")
    .And(f => f.Assignee == "john.doe")
    .Or(f => f.Status == "In Progress");

Ordering

  • OrderBy: Specify the primary ordering field.
  • OrderByDescending: Specify the primary ordering field in descending order.
  • ThenBy: Add secondary ordering fields.
  • ThenByDescending: Add secondary ordering fields in descending order.
JqlBuilder.Query
    .OrderBy(f => f.Project)
    .ThenByDescending(f => f.Priority)
    .ThenBy(f => f.Assignee);

Building

The ToString method is used to obtain the final JQL query string.

JqlBuilder.Query
    .Where(f => f.Project == "example")
    .And(f => f.Assignee == "john.doe")
    .OrderBy(f => f.Project)
    .ThenByDescending(f => f.Priority)
    .ToString();

Examples:

Below are examples demonstrating the usage of the JqlBuilder library based on the provided test class.

Example 1: Basic Query Construction

JqlBuilder.Query
    .Where(f => f.Project == "CLOVER")
    .And(f => f.Project == 12345)
    .And(f => f.Project.In("CLOVER", 12345))
    .And(f => f.Project.In(func => func.LeadByUser("hulk@avengers.world")) | (f.Project == "CLOVER"))
    .And(f => f.Project.NotIn(func => func.WhereUserHasRole("hulk@avengers.world")))
    .ToString();

Generated JQL:

    project = "CLOVER" AND project = 12345 AND project in ("CLOVER", 12345) AND (project in projectsLeadByUser("hulk@avengers.world") OR project = "CLOVER") AND project not in projectsWhereUserHasRole("hulk@avengers.world")

Example 2: OR Condition with Ordering

JqlBuilder.Query
    .Where(f => f.Project == "CLOVER")
    .Or(f => f.Project == "HEARTH")
    .OrderBy(f => f.Project)
    .ThenByDescending(f => f.Assignee)
    .ToString();

Generated JQL:

    project = "CLOVER" OR project = "HEARTH" order by project asc, assignee desc

Example 3: Ordering Without Filtering

JqlBuilder.Query
    .OrderBy(f => f.Project)
    .ThenByDescending(f => f.Assignee)
    .ThenBy(f => f.Assignee)
    .ToString();

Generated JQL:

    order by project asc, assignee desc, assignee asc

Example 4: Complex Nested Conditions

JqlBuilder.Query
    .Where(f => f.Project == "CLOVER")
    .And(f => (f.Project == 12345) | f.Project.In("CLOVER", 12345))
    .ToString();

Generated JQL:

    project = "CLOVER" AND (project = 12345 OR project in ("CLOVER", 12345))

Example 5: Nested AND and OR Conditions

JqlBuilder.Query
    .Where(f => f.Project == "CLOVER")
    .And(f => (f.Project == 12345) | ((f.Project == "HEARTH") & (f.Project == "SPADE")))
    .ToString();

Generated JQL:

    project = "CLOVER" AND (project = 12345 OR project = "HEARTH" AND project = "SPADE")

Example 6: NOT Conditions

JqlBuilder.Query
    .Where(f => !(f.Project == "CLOVER"))
    .And(f => (f.Project == 12345) | ((f.Project == "HEARTH") & (f.Project == "SPADE")))
    .ToString();

Generated JQL:

    NOT(project = "CLOVER") AND (project = 12345 OR project = "HEARTH" AND project = "SPADE")

Example 7: Double NOT Conditions

JqlBuilder.Query
    .Where(f => !!(f.Project == "CLOVER"))
    .And(f => (f.Project == 12345) | ((f.Project == "HEARTH") & (f.Project == "SPADE")))
    .ToString();

Generated JQL:

    NOT NOT(project = "CLOVER") AND (project = 12345 OR project = "HEARTH" AND project = "SPADE")

Example 8: Double NOT Condition Only

JqlBuilder.Query
    .Where(f => !!(f.Project == "CLOVER"))
    .ToString();

Generated JQL:

    NOT NOT(project = "CLOVER")

Example 9: NULL and NOT EMPTY Conditions

JqlBuilder.Query
    .Where(f => f.Project.Is(v => v.Null))
    .And(f => (f.Project == 12345) | f.Project.IsNot(v => v.Empty))
    .ToString();

Generated JQL:

    project is NULL AND (project = 12345 OR project is not EMPTY)
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

  • net8.0

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
1.3.0 86 2/18/2024
1.3.0-pre.77b50f4 48 2/18/2024
1.2.0 89 1/30/2024
1.1.5 85 1/28/2024
1.1.4 76 1/28/2024
1.1.3 91 1/28/2024
1.1.2 85 1/28/2024
1.1.1 95 1/28/2024
1.1.0 117 1/28/2024
1.0.92 98 1/20/2024
1.0.92-alpha1.0.d94cc32 57 1/20/2024
1.0.91 152 12/23/2023
1.0.91-alpha1.0.80949c7 82 12/23/2023
1.0.90 99 12/23/2023
1.0.90-alpha1.0.7d5d4e8 67 12/23/2023
1.0.80 96 12/23/2023
1.0.80-alpha1.2.7d5d4e8 74 12/23/2023
1.0.80-alpha1.0.66c47d0 74 12/23/2023
1.0.72 90 12/23/2023
1.0.72-alpha.e6eaa37 70 12/23/2023
1.0.71-rc.ffc43be 73 12/23/2023
1.0.70-rc.f8a64fd 72 12/23/2023
1.0.60-rc.48b70041a5d29a1b4... 73 12/23/2023
1.0.50-rc 89 12/23/2023
1.0.43-pre 71 12/23/2023
1.0.42 105 12/23/2023
1.0.41 103 12/23/2023
1.0.40 120 12/23/2023
1.0.20 109 12/22/2023
1.0.19 107 12/22/2023
1.0.10 115 12/22/2023
1.0.9 112 12/22/2023
1.0.8 108 12/22/2023
1.0.7 104 12/22/2023
1.0.1 113 12/22/2023
1.0.0 95 12/21/2023