QueryBuildersDotNET 1.0.5

SQL query builders for the .NET framework

Install-Package QueryBuildersDotNET -Version 1.0.5
dotnet add package QueryBuildersDotNET --version 1.0.5
<PackageReference Include="QueryBuildersDotNET" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QueryBuildersDotNET --version 1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

QueryBuilders.NET

SQL query builders for the .NET framework

Example

string region = "RJ";
string city = "Rio de Janeiro";
bool readReportsTo = true;

SelectQueryBuilder builder = new SelectQueryBuilder();
builder.AddFrom("orders");
builder.AddField("orders.orderid");
builder.AddField("orders.customerid");
builder.AddField("orders.employeeid");
builder.Where.Add("orders.shipregion = {0}", region);
builder.Where.AddEqualsObject("orders.shipcity", city);
builder.AddOrderBy("orders.orderid", true);
if (readReportsTo)
{
    builder.AddJoin("employees").On.Add("orders.employeeid = employees.employeeid");
    builder.AddField("employees.reportsto");
}
Console.WriteLine(builder);
// SELECT orders.orderid, orders.customerid, orders.employeeid, employees.reportsto
// FROM orders
// INNER JOIN employees ON orders.employeeid = employees.employeeid
// WHERE orders.shipregion = @p_0 AND orders.shipcity = @p_1
// ORDER BY orders.orderid ASC

using (IDbCommand command = connection.CreateCommand())
{
    // Sets the CommandText property, as well as values for p_0 and p_1 parameters
    builder.PrepareDbCommand(command);
    using (var reader = command.ExecuteReader())
    {
        while (reader.Read())
        {
            // Read rows...
        }
    }
}

// Also integrates with Dapper using the QueryBuildersDotNet.Dapper package
var results = connection.Query(builder);

QueryBuilders.NET

SQL query builders for the .NET framework

Example

string region = "RJ";
string city = "Rio de Janeiro";
bool readReportsTo = true;

SelectQueryBuilder builder = new SelectQueryBuilder();
builder.AddFrom("orders");
builder.AddField("orders.orderid");
builder.AddField("orders.customerid");
builder.AddField("orders.employeeid");
builder.Where.Add("orders.shipregion = {0}", region);
builder.Where.AddEqualsObject("orders.shipcity", city);
builder.AddOrderBy("orders.orderid", true);
if (readReportsTo)
{
    builder.AddJoin("employees").On.Add("orders.employeeid = employees.employeeid");
    builder.AddField("employees.reportsto");
}
Console.WriteLine(builder);
// SELECT orders.orderid, orders.customerid, orders.employeeid, employees.reportsto
// FROM orders
// INNER JOIN employees ON orders.employeeid = employees.employeeid
// WHERE orders.shipregion = @p_0 AND orders.shipcity = @p_1
// ORDER BY orders.orderid ASC

using (IDbCommand command = connection.CreateCommand())
{
    // Sets the CommandText property, as well as values for p_0 and p_1 parameters
    builder.PrepareDbCommand(command);
    using (var reader = command.ExecuteReader())
    {
        while (reader.Read())
        {
            // Read rows...
        }
    }
}

// Also integrates with Dapper using the QueryBuildersDotNet.Dapper package
var results = connection.Query(builder);

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.5 267 5/17/2019
1.0.4 133 4/2/2019
1.0.3 157 12/8/2018
1.0.2 119 12/4/2018