Fastql 1.0.2
Earlier versions are no longer available. There are huge improvements and bug fixes in package. Please use version 1.4.2.6 and higher.
See the version list below for details.
dotnet add package Fastql --version 1.0.2
NuGet\Install-Package Fastql -Version 1.0.2
<PackageReference Include="Fastql" Version="1.0.2" />
paket add Fastql --version 1.0.2
#r "nuget: Fastql, 1.0.2"
// Install Fastql as a Cake Addin
#addin nuget:?package=Fastql&version=1.0.2
// Install Fastql as a Cake Tool
#tool nuget:?package=Fastql&version=1.0.2
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;
Sample Code
Check out the Fastql Sample Project with Unit of Work in Repository Pattern using Dapper.
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 ⚡ InsertQuery ⚡ UpdateQuery ⚡ SelectQuery ⚡ DeleteQuery
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)
SelectQuery(where)
SelectQuery(where) function returns you the select query based on your where condition.
Connection.Query<TEntity>(
fastql.SelectQuery("Id=@Id"),
param: new { Id = id },
transaction: Transaction
);
SelectQuery(columns,where,top)
SelectQuery(columns,where,top) function returns you the select query based on desired columns, where conditions and top records.
Connection.Query<TEntity>(
fastql.SelectQuery(new string[] {"Field1","Field2","Field3"},"Id=@Id"),
param: new { Id = id },
transaction: Transaction
);
Sample output: Select TOP(1000) [Field1],[Field2],[Field3] from [TableName] where Id=@Id
Connection.Query<TEntity>(
fastql.SelectQuery(new string[] {"Field1","Field2","Field3"},"Id=@Id",500),
param: new { Id = id },
transaction: Transaction
);
Sample output: Select TOP(500) [Field1],[Field2],[Field3] from [TableName] where Id=@Id
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
DeleteQuery(where) function returns you the delete query based on your where condition.
Connection.Execute(
fastql.DeleteQuery(where),
// param: entity,
transaction: Transaction
);
Product | Versions 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. |
-
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.