Fastql 1.0.0

Additional Details

Earlier versions are no longer available. There are huge improvements and bug fixes in package. Please use version 1.4.2.6 and higher.

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

// Install Fastql as a Cake Tool
#tool nuget:?package=Fastql&version=1.0.0

Overview

What is the ⚡Fastql?

A small and fast library for building SQL queries from entity classes in a better way than regular string concatenation.

Get Started

Install Package

⚡ Add package to your existing project from NuGet Package Manager. <br> ⚡ Or download the source code from GitHub.

Import the namespace

using Fastsql;

How to use

Define a FastqlBuilder variable in your database related class. TEntity should be your poco to generate Insert and Update queries.

⚡ This class fits perfect to Repository Pattern with Dapper Micro ORM.

   private FastqlBuilder<TEntity> fastql;

Constructor needs an object to handle attributes of the demanded class at runtime. If you don't have any at design time, you can initialize your fastql like this:

fastql = new FastqlBuilder<TEntity>((TEntity)Activator.CreateInstance(typeof(TEntity)));

(Activator is in namespace System in assembly System.Runtime.dll)

Prepare Your Entity

Fastql has 4 attributes to handle your queries.

Table Attribute

Define your table and schema name. If you don't set your schema, it'll use dbo as default.

 [Table("Customer", "Sales")]
    public class Customer
    {

It will be rendered like [Sales].[Customer] for your query.

IsPrimaryKey Attribute

If your database table has PK and auto increment, you should define this attribute to your PK field. If your field has this key, your field won't be used in Insert or Update query.

 [Table("Customer", "Sales")]
    public class Customer
    {
        [IsPrimaryKey]
        public int Id { get; set; }
    }

IsNotInsertable Attribute

Fields have this attribute won't be placed in your Insert query. You don't need to define this key for your PK field.

[IsNotInsertable]
public DateTime UpdatedOn { get; set; }

IsNotUpdatable Attribute

Fields have this attribute won't be placed in your Update query. You don't need to define this key for your PK field.

[IsNotUpdatable]
public DateTime CreatedOn { get; set; }

APIs

⚡ TableName <br> ⚡ InsertQuery <br> ⚡ UpdateQuery <br>

Dapper Example

⚡Fastql is a great extension for Dapper Micro ORM. You can handle all of your CRUD operations easily with ⚡Fastql.

CRUD Operations

Create (Insert)

InsertQuery() function returns you the insert query based on your decisions.

Connection.Execute(
                fastql.InsertQuery(),
                param: entity,
                transaction: Transaction
               );

Read (Select)

TableName() function returns you the schema and table for ready-to-use in select query.

Connection.Query<TEntity>(
                  $"SELECT * FROM {fastql.TableName()} WHERE Id=@Id",
                  param: new { Id = id },
                  transaction: Transaction
              );

Update

UpdateQuery(TEntity,string) returns you the update query with parameter tags added. You can bind your entity to query as parameter. Where string can include data or you can set your param tag to use it. (For.ex.) "Id=@Id" or $"Id={id}"

Connection.Execute(
                  fastql.UpdateQuery(entity, where),
                  param: entity,
                  transaction: Transaction
              );

Delete

TableName() function can be used for delete operation too. You can handle your where condition with your way.

Connection.Execute(
                  $"DELETE FROM {fastql.TableName()} WHERE {where}",
                  // param: entity,
                  transaction: Transaction
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 was computed.  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

    • 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
2.4.1 309 2/8/2023
2.2.1 309 1/23/2023
2.2.0 300 1/20/2023
2.1.2 1,071 7/12/2022
2.1.0 604 7/9/2022
1.4.2.9 444 7/8/2022
1.4.2.7 471 7/3/2022
1.4.2.6 484 7/2/2022
1.4.2.4 627 6/19/2022
1.3.1 641 12/16/2021
1.1.1 666 10/24/2021
1.0.2 690 10/11/2021
1.0.0 732 9/30/2021