QueryGen.Core
1.0.0
dotnet add package QueryGen.Core --version 1.0.0
NuGet\Install-Package QueryGen.Core -Version 1.0.0
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="QueryGen.Core" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QueryGen.Core --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: QueryGen.Core, 1.0.0"
#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 QueryGen.Core as a Cake Addin #addin nuget:?package=QueryGen.Core&version=1.0.0 // Install QueryGen.Core as a Cake Tool #tool nuget:?package=QueryGen.Core&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Query Generator
Easy SQL Query Generator from C# Lambda Expressions.
Installation
After installing this package, you should see QueryGen.Core.dll
in your .NET project.
How To Use
- Define a POCO class. Let's say Person.cs.
- Initialize and get an instance of SQLBuilder
SQLBuilder<Person> builder = SQLBuilder<Person>.GetInstance;
Person.cs
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace QueryGen.Test.Model
{
[Table("PersonDetails")]
public class Person
{
public int Id { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
[Column("BirthDate")]
public DateTime? DOB { get; set; }
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
public string Country { get; set; }
}
}
Example 1: To fetch all the person(s) whose firstname starts with letter "P"
- **C# 😗*
string query = builder.StartsWith(x => x.Firstname, "P").GetSQL();
- **Output 😗*
WHERE (LTRIM(RTRIM(LOWER([Firstname]))) LIKE 'p%' )
Example 2: To fetch all the person(s) whose firstname starts with letter "P" and age is between 5 and 20
- **C# 😗*
string query = builder.StartsWith(x => x.Firstname, "P").Between<DateTime>(x => x.DOB, DateTime.Now.AddYears(-20), DateTime.Now.AddYears(-5)).GetSQL();
- **Output 😗*
WHERE (LTRIM(RTRIM(LOWER([Firstname]))) LIKE 'p%' ) ( [DOB] BETWEEN 2000-03-08 AND 2015-03-08 )
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net48 is compatible. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
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.0.0 | 594 | 3/7/2020 |
This is an initial release.