QueryBuildersDotNET.Dapper 1.0.3

Provides multiple methods to integrate QueryBuilders.NET with the Dapper micro-orm

Install-Package QueryBuildersDotNET.Dapper -Version 1.0.3
dotnet add package QueryBuildersDotNET.Dapper --version 1.0.3
<PackageReference Include="QueryBuildersDotNET.Dapper" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QueryBuildersDotNET.Dapper --version 1.0.3
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.3 168 12/8/2018