diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 574626ca..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,144 +0,0 @@ -name: .NET Core -on: - push: - pull_request: - release: - types: - - published -env: - # Stop wasting time caching packages - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - # Disable sending usage data to Microsoft - DOTNET_CLI_TELEMETRY_OPTOUT: true - # Project name to pack and publish - PROJECT_NAME: SqlKata - DOTNET_VERSION: 6.0.202 - # DOTNET_VERSION: 5.0.201 - # DOTNET_VERSION: 2.2.203 - # GitHub Packages Feed settings - GITHUB_FEED: https://nuget.pkg.github.com/sqlkata/ - GITHUB_USER: ahmad-moussawi - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Official NuGet Feed settings - NUGET_FEED: https://api.nuget.org/v3/index.json - NUGET_KEY: ${{ secrets.NUGET_KEY }} - - DB_MYSQL_DATABASE: test_sqlkata - DB_MYSQL_USER: root - DB_MYSQL_PASSWORD: 'root' - DB_MYSQL_HOST: localhost - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Checking release - run: | - echo $RELEASE_VERSION - echo ${{ env.RELEASE_VERSION }} - - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: ${{ env.DOTNET_VERSION }} - - - name: Restore - run: dotnet restore - - - name: Build - run: dotnet build -c Release --no-restore - - - name: Start MySql - run: | - sudo /etc/init.d/mysql start - mysqladmin -u ${{ env.DB_MYSQL_USER }} -p${{ env.DB_MYSQL_PASSWORD }} password '' - mysql -e 'CREATE DATABASE ${{ env.DB_MYSQL_DATABASE }};' -u${{ env.DB_MYSQL_USER }} - mysql -e 'CREATE TABLE cars(id int primary key auto_increment);' -u${{ env.DB_MYSQL_USER }} ${{ env.DB_MYSQL_DATABASE }} - mysql -e 'SHOW TABLES;' -u${{ env.DB_MYSQL_USER }} ${{ env.DB_MYSQL_DATABASE }} - - - name: Test - run: dotnet test -c Release - env: - SQLKATA_MYSQL_HOST: ${{ env.DB_MYSQL_HOST }} - SQLKATA_MYSQL_USER: ${{ env.DB_MYSQL_USER }} - SQLKATA_MYSQL_DB: ${{ env.DB_MYSQL_DATABASE }} - - - name: Pack QueryBuilder - if: matrix.os == 'ubuntu-latest' - run: dotnet pack -v normal -c Release --no-restore --include-symbols --include-source --version-suffix=$GITHUB_RUN_ID QueryBuilder/QueryBuilder.csproj - - - name: Pack SqlKata.Execution - if: matrix.os == 'ubuntu-latest' - run: dotnet pack -v normal -c Release --no-restore --include-symbols --include-source --version-suffix=$GITHUB_RUN_ID SqlKata.Execution/SqlKata.Execution.csproj - - - name: Upload QueryBuilder Artifact - if: matrix.os == 'ubuntu-latest' - uses: actions/upload-artifact@v2 - with: - name: nupkg - path: ./QueryBuilder/bin/Release/*.nupkg - - - name: Upload SqlKata.Execution Artifact - if: matrix.os == 'ubuntu-latest' - uses: actions/upload-artifact@v2 - with: - name: nupkg - path: ./SqlKata.Execution/bin/Release/*.nupkg - prerelease: - needs: build - if: github.ref == 'refs/heads/develop' - runs-on: ubuntu-latest - steps: - - name: Download Artifact - uses: actions/download-artifact@v1 - with: - name: nupkg - - name: Push to GitHub Feed - run: | - for f in ./nupkg/*.nupkg - do - if [[ ${f} != *".symbols."* ]];then - echo "Uploading package $f" to $GITHUB_FEED - dotnet nuget push $f --api-key=$GITHUB_TOKEN --source=$GITHUB_FEED - fi - # curl -X PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED - done - deploy: - needs: build - if: github.event_name == 'release' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: ${{ env.DOTNET_VERSION }} - - name: Create Release NuGet package (QueryBuilder) - run: | - arrTag=(${GITHUB_REF//\// }) - VERSION="${arrTag[2]}" - echo Version: $VERSION - VERSION="${VERSION//v}" - echo Clean Version: $VERSION - dotnet pack -v normal -c Release --include-symbols --include-source -p:Version=$VERSION -p:PackageVersion=$VERSION -o nupkg QueryBuilder/QueryBuilder.csproj - - name: Create Release NuGet package (SqlKata.Execution) - run: | - arrTag=(${GITHUB_REF//\// }) - VERSION="${arrTag[2]}" - echo Version: $VERSION - VERSION="${VERSION//v}" - echo Clean Version: $VERSION - dotnet pack -v normal -c Release --include-symbols --include-source -p:Version=$VERSION -p:PackageVersion=$VERSION -o nupkg SqlKata.Execution/SqlKata.Execution.csproj - - name: Push to GitHub Feed - run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source $GITHUB_FEED --api-key $GITHUB_TOKEN - - name: Push to NuGet Feed - run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source $NUGET_FEED --api-key $NUGET_KEY diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..4603b547 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,80 @@ +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] +env: + # Stop wasting time caching packages + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + # Disable sending usage data to Microsoft + DOTNET_CLI_TELEMETRY_OPTOUT: true + + # MYSQL DB + DB_MYSQL_DATABASE: test_sqlkata + + # MS SQL + DB_MSSQL_HOST: localhost + DB_MSSQL_USER: sa + DB_MSSQL_DATABASE: test_sqlkata + + +jobs: + build: + runs-on: ubuntu-latest + # Define a service container for SQL Server + # services: + # mssql: + # image: mcr.microsoft.com/mssql/server:2022-latest + # env: + # MSSQL_SA_PASSWORD: "${{ secrets.MSSQL_SA_PASSWORD }}" + # ACCEPT_EULA: 'Y' + # MSSQL_PID: Express + # ports: + # - 1433:1433 # Map the port + # # Wait for the service to be ready before running steps + # options: >- + # --health-cmd "sqlcmd -S localhost -U sa -P $SA_PASSWORD -Q 'SELECT 1'" + # --health-interval 10s + # --health-timeout 5s + # --health-retries 20 + + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Start MySql + run: | + sudo /etc/init.d/mysql start + mysqladmin -u root -proot password "${{ secrets.MYSQL_ROOT_PASSWORD }}" + mysql -uroot -p"${{ secrets.MYSQL_ROOT_PASSWORD }}" -e 'CREATE DATABASE ${{ env.DB_MYSQL_DATABASE }};' + mysql -uroot -p"${{ secrets.MYSQL_ROOT_PASSWORD }}" -e 'CREATE TABLE cars(id int primary key auto_increment);' ${{ env.DB_MYSQL_DATABASE }} + mysql -uroot -p"${{ secrets.MYSQL_ROOT_PASSWORD }}" -e 'SHOW TABLES;' ${{ env.DB_MYSQL_DATABASE }} + + # - name: Install sqlcmd tools + # run: | + # sudo apt-get update + # sudo apt-get install -y curl apt-transport-https gnupg + # curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc + # echo "deb [arch=amd64,arm64,armhf] https://packages.microsoft.com/ubuntu/$(lsb_release -rs)/prod $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/microsoft.list + # sudo apt-get update + # sudo apt-get install -y mssql-tools unixodbc-dev + # echo '/opt/mssql-tools/bin' | sudo tee -a $GITHUB_PATH + + # - name: Run SQL commands (example) + # run: | + # sqlcmd -S localhost,1433 -U SA -P "${{ secrets.MSSQL_SA_PASSWORD }}" -Q "SELECT @@VERSION" + + - name: Run Test + run: dotnet test --no-build --verbosity normal + env: + SQLKATA_MYSQL_HOST: localhost + SQLKATA_MYSQL_USER: root + SQLKATA_MYSQL_DB: ${{ env.DB_MYSQL_DATABASE }} + SQLKATA_MYSQL_PASSWORD: "${{ secrets.MYSQL_ROOT_PASSWORD }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..ad7b033d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" +env: + # Stop wasting time caching packages + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + # Disable sending usage data to Microsoft + DOTNET_CLI_TELEMETRY_OPTOUT: true + + # MYSQL DB + DB_MYSQL_DATABASE: test_sqlkata + DB_MYSQL_USER: root + DB_MYSQL_PASSWORD: "root" + DB_MYSQL_HOST: localhost +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Verify commit exists in origin/main + run: git branch --remote --contains | grep origin/main + # - name: Extract release notes + # run: | + # git log --pretty=format:'%d %s' ${GITHUB_REF} | perl -pe 's| \(.*tag: v(\d+.\d+.\d+(-preview\d{3})?)(, .*?)*\)|\n## \1\n|g' > RELEASE-NOTES + - name: Set VERSION variable from tag + run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV + - name: Build + run: dotnet build --configuration Release /p:Version=${VERSION} + - name: Start MySql + run: | + sudo /etc/init.d/mysql start + mysqladmin -u ${{ env.DB_MYSQL_USER }} -p${{ env.DB_MYSQL_PASSWORD }} password '' + mysql -e 'CREATE DATABASE ${{ env.DB_MYSQL_DATABASE }};' -u${{ env.DB_MYSQL_USER }} + mysql -e 'CREATE TABLE cars(id int primary key auto_increment);' -u${{ env.DB_MYSQL_USER }} ${{ env.DB_MYSQL_DATABASE }} + mysql -e 'SHOW TABLES;' -u${{ env.DB_MYSQL_USER }} ${{ env.DB_MYSQL_DATABASE }} + - name: Test + run: dotnet test --configuration Release /p:Version=${VERSION} --no-build + env: + SQLKATA_MYSQL_HOST: ${{ env.DB_MYSQL_HOST }} + SQLKATA_MYSQL_USER: ${{ env.DB_MYSQL_USER }} + SQLKATA_MYSQL_DB: ${{ env.DB_MYSQL_DATABASE }} + - name: Pack + run: dotnet pack --configuration Release /p:Version=${VERSION} --no-build --output . + - name: Push to Github Packages + run: dotnet nuget push *.${VERSION}.nupkg --skip-duplicate --source https://nuget.pkg.github.com/sqlkata/index.json --api-key ${GITHUB_TOKEN} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Push to Nuget + run: dotnet nuget push *.${VERSION}.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${NUGET_KEY} + env: + NUGET_KEY: ${{ secrets.NUGET_KEY }} diff --git a/Program/Program.cs b/Program/Program.cs deleted file mode 100644 index 9b4c2845..00000000 --- a/Program/Program.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Collections.Generic; -using SqlKata; -using SqlKata.Compilers; -using SqlKata.Execution; -using System.Data.SqlClient; -using System.Threading.Tasks; -using System.Linq; -using Newtonsoft.Json; -using Npgsql; -using System.Data; -using Dapper; -using System.Data.SQLite; -using static SqlKata.Expressions; -using System.IO; - -namespace Program -{ - class Program - { - private class Loan - { - public string Id { get; set; } - public string Name { get; set; } - public List Installments { get; set; } = new List(); - } - - private class Installment - { - public string Id { get; set; } - public string LoanId { get; set; } - public int DaysCount { get; set; } - } - - static void Main(string[] args) - { - using (var db = SqlLiteQueryFactory()) - { - var query = db.Query("accounts") - .Where("balance", ">", 0) - .GroupBy("balance") - .Limit(10); - - var accounts = query.Clone().Get(); - Console.WriteLine(JsonConvert.SerializeObject(accounts, Formatting.Indented)); - - var exists = query.Clone().Exists(); - Console.WriteLine(exists); - } - } - - private static void log(Compiler compiler, Query query) - { - var compiled = compiler.Compile(query); - Console.WriteLine(compiled.ToString()); - Console.WriteLine(JsonConvert.SerializeObject(compiled.Bindings)); - } - - private static QueryFactory SqlLiteQueryFactory() - { - var compiler = new SqliteCompiler(); - - var connection = new SQLiteConnection("Data Source=Demo.db"); - - var db = new QueryFactory(connection, compiler); - - db.Logger = result => - { - Console.WriteLine(result.ToString()); - }; - - if (!File.Exists("Demo.db")) - { - Console.WriteLine("db not exists creating db"); - - SQLiteConnection.CreateFile("Demo.db"); - - db.Statement("create table accounts(id integer primary key autoincrement, name varchar, currency_id varchar, balance decimal, created_at datetime);"); - for (var i = 0; i < 10; i++) - { - db.Statement("insert into accounts(name, currency_id, balance, created_at) values(@name, @currency, @balance, @date)", new - { - name = $"Account {i}", - currency = "USD", - balance = 100 * i * 1.1, - date = DateTime.UtcNow, - }); - } - - } - - return db; - - } - - private static QueryFactory SqlServerQueryFactory() - { - var compiler = new PostgresCompiler(); - var connection = new SqlConnection( - "Server=tcp:localhost,1433;Initial Catalog=Lite;User ID=sa;Password=P@ssw0rd" - ); - - var db = new QueryFactory(connection, compiler); - - db.Logger = result => - { - Console.WriteLine(result.ToString()); - }; - - return db; - } - - } -} diff --git a/Program/Program.csproj b/Program/Program.csproj deleted file mode 100644 index a5ac20c5..00000000 --- a/Program/Program.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - Exe - false - netcoreapp2.0 - - - diff --git a/QueryBuilder.Tests/MySqlExecutionTest.cs b/QueryBuilder.Tests/MySqlExecutionTest.cs index 07df93c8..259dcccf 100644 --- a/QueryBuilder.Tests/MySqlExecutionTest.cs +++ b/QueryBuilder.Tests/MySqlExecutionTest.cs @@ -174,7 +174,7 @@ public void ExistsShouldReturnFalseForEmptyTable() }); var exists = db.Query("Transaction").Exists(); - Assert.Equal(false, exists); + Assert.False(exists); db.Drop("Transaction"); } @@ -195,7 +195,7 @@ public void ExistsShouldReturnTrueForNonEmptyTable() }); var exists = db.Query("Transaction").Exists(); - Assert.Equal(true, exists); + Assert.True(exists); db.Drop("Transaction"); } @@ -213,12 +213,12 @@ public void BasicSelectFilter() // 2020 {"2020-01-01", 10}, {"2020-05-01", 20}, - + // 2021 {"2021-01-01", 40}, {"2021-02-01", 10}, {"2021-04-01", -10}, - + // 2022 {"2022-01-01", 80}, {"2022-02-01", -30}, @@ -251,10 +251,11 @@ public void BasicSelectFilter() QueryFactory DB() { - var host = System.Environment.GetEnvironmentVariable("SQLKATA_MYSQL_HOST"); - var user = System.Environment.GetEnvironmentVariable("SQLKATA_MYSQL_USER"); - var dbName = System.Environment.GetEnvironmentVariable("SQLKATA_MYSQL_DB"); - var cs = $"server={host};user={user};database={dbName}"; + var host = Environment.GetEnvironmentVariable("SQLKATA_MYSQL_HOST"); + var user = Environment.GetEnvironmentVariable("SQLKATA_MYSQL_USER"); + var dbName = Environment.GetEnvironmentVariable("SQLKATA_MYSQL_DB"); + var dbPass = Environment.GetEnvironmentVariable("SQLKATA_MYSQL_PASSWORD"); + var cs = $"Server={host};User={user};Database={dbName};Password={dbPass}"; var connection = new MySqlConnection(cs); @@ -266,4 +267,4 @@ QueryFactory DB() } -} \ No newline at end of file +} diff --git a/QueryBuilder.Tests/QueryBuilder.Tests.csproj b/QueryBuilder.Tests/QueryBuilder.Tests.csproj index 92829215..ae34193c 100755 --- a/QueryBuilder.Tests/QueryBuilder.Tests.csproj +++ b/QueryBuilder.Tests/QueryBuilder.Tests.csproj @@ -1,19 +1,24 @@ - - net6.0 - Library - false - SqlKata.Tests - - - - - - - - - - - - - \ No newline at end of file + + net8.0 + Library + false + SqlKata.Tests + + + + + + + + + + + + + diff --git a/QueryBuilder/Compilers/Compiler.cs b/QueryBuilder/Compilers/Compiler.cs index 6bb208ea..5ac6c080 100644 --- a/QueryBuilder/Compilers/Compiler.cs +++ b/QueryBuilder/Compilers/Compiler.cs @@ -229,7 +229,7 @@ protected virtual SqlResult CompileSelectQuery(Query query) protected virtual SqlResult CompileAdHocQuery(AdHocTableFromClause adHoc) { - var ctx = new SqlResult(); + var ctx = new SqlResult(parameterPlaceholder, EscapeCharacter); var row = "SELECT " + string.Join(", ", adHoc.Columns.Select(col => $"{parameterPlaceholder} AS {Wrap(col)}")); diff --git a/QueryBuilder/Compilers/SqlServerCompiler.cs b/QueryBuilder/Compilers/SqlServerCompiler.cs index a1b7da55..98b488bf 100644 --- a/QueryBuilder/Compilers/SqlServerCompiler.cs +++ b/QueryBuilder/Compilers/SqlServerCompiler.cs @@ -173,7 +173,7 @@ protected override string CompileBasicDateCondition(SqlResult ctx, BasicDateCond protected override SqlResult CompileAdHocQuery(AdHocTableFromClause adHoc) { - var ctx = new SqlResult(); + var ctx = new SqlResult(parameterPlaceholder, EscapeCharacter); var colNames = string.Join(", ", adHoc.Columns.Select(Wrap)); diff --git a/QueryBuilder/QueryBuilder.csproj b/QueryBuilder/QueryBuilder.csproj index 5ce65d65..d30c6789 100755 --- a/QueryBuilder/QueryBuilder.csproj +++ b/QueryBuilder/QueryBuilder.csproj @@ -1,36 +1,25 @@ - - SqlKata The C# Sql Query Builder - A powerful Dynamic Sql Query Builder supporting Sql Server, MySql, PostgreSql, Oracle and Firebird - Ahmad Moussawi - Copyright (c) 2017 Ahmad Moussawi - netstandard2.0 - SqlKata - SqlKata - - - SqlKata - sql;query-builder;dynamic-query - https://github.com/sqlkata/querybuilder - https://github.com/sqlkata/querybuilder - true - MIT - git - https://github.com/sqlkata/querybuilder - - - true - true - CS1591 - - - bin\Debug\netstandard2.0\SqlKata.xml - - - bin\Release\netstandard2.0\SqlKata.xml - - - - - + + SqlKata + A powerful Dynamic Sql Query Builder supporting SQL Server, MySql, PostgreSql, Sqlite, and Oracle + Ahmad Moussawi + Copyright (c) 2017 Ahmad Moussawi + net8.0 + SqlKata + SqlKata.Core + + SqlKata + sql;query-builder;dynamic-query + https://github.com/sqlkata/querybuilder + https://github.com/sqlkata/querybuilder + true + MIT + git + https://github.com/sqlkata/querybuilder + + true + true + CS1591 + + \ No newline at end of file diff --git a/README.md b/README.md index d07b1216..b911d738 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- SqlKata Query Builder + SqlKata Query Builder

@@ -9,31 +9,24 @@ Twitter

-

-Follow and Upvote SqlKata on Product Hunt to encourage the development of this project + Follow and Upvote SqlKata on Product Hunt to encourage the development of this project

-SqlKata - Dynamic Sql query builder for dotnet | Product Hunt + SqlKata - Dynamic Sql query builder for dotnet | Product Hunt

+https://private-user-images.githubusercontent.com/2517523/408899411-1f9ff89b-ed17-4d02-ae2f-afc1c66a5932.mp4 -![Quick Demo](https://i.imgur.com/jOWD4vk.gif) - - -SqlKata Query Builder is a powerful Sql Query Builder written in C#. - -It's secure and framework agnostic. Inspired by the top Query Builders available, like Laravel Query Builder and Knex. - -SqlKata has an expressive API. it follows a clean naming convention, which is very similar to the SQL syntax. - -By providing a level of abstraction over the supported database engines, that allows you to work with multiple databases with the same unified API. +## 🚀 Introduction -SqlKata supports complex queries, such as nested conditions, selection from SubQuery, filtering over SubQueries, Conditional Statements and others. Currently, it has built-in compilers for SqlServer, MySql, PostgreSQL, and Firebird. +SqlKata Query Builder is a powerful SQL query builder written in C#. It is secure, framework-agnostic, and inspired by top query builders like Laravel Query Builder and Knex. -The SqlKata.Execution package provides the ability to submit the queries to the database, using [Dapper](https://github.com/StackExchange/Dapper) under the covers. - -Checkout the full documentation on [https://sqlkata.com](https://sqlkata.com) +### ✨ Key Features +- **Expressive API**: Clean and intuitive syntax similar to SQL. +- **Database Agnostic**: Work with multiple databases using a unified API. +- **Complex Queries**: Supports nested conditions, subqueries, conditional statements, and more. +- **Execution Support**: Use the SqlKata.Execution package to execute queries with Dapper. ## Installation @@ -42,7 +35,6 @@ $ dotnet add package SqlKata $ dotnet add package SqlKata.Execution # (optional) If you want the execution support ``` - ## Quick Examples ### Setup Connection @@ -50,40 +42,43 @@ $ dotnet add package SqlKata.Execution # (optional) If you want the execution su ```cs var connection = new SqlConnection("..."); var compiler = new SqlCompiler(); - -var db = new QueryFactory(connection, compiler) +var db = new QueryFactory(connection, compiler); ``` - > `QueryFactory` is provided by the SqlKata.Execution package. ### Retrieve all records + ```cs var books = db.Query("Books").Get(); ``` ### Retrieve published books only + ```cs var books = db.Query("Books").WhereTrue("IsPublished").Get(); ``` ### Retrieve one book + ```cs var introToSql = db.Query("Books").Where("Id", 145).Where("Lang", "en").First(); ``` ### Retrieve recent books: last 10 + ```cs var recent = db.Query("Books").OrderByDesc("PublishedAt").Limit(10).Get(); ``` ### Include Author information + ```cs var books = db.Query("Books") - .Include(db.Query("Authors")) // Assumes that the Books table have a `AuthorId` column + .Include(db.Query("Authors")) // Assumes that the Books table has an `AuthorId` column .Get(); ``` -This will include the property "Author" on each "Book" +This will include the property "Author" on each "Book": ```jsonc [{ "Id": 1, @@ -111,6 +106,7 @@ foreach(var book in books) ``` ### Conditional queries + ```cs var isFriday = DateTime.Today.DayOfWeek == DayOfWeek.Friday; @@ -159,16 +155,22 @@ int affected = db.Query("Users").Where("Id", 1).Delete(); ``` ## FAQ + ### How to know when a new release or a feature is available? -I announce updates on My [Twitter Account](https://twitter.com/ahmadmuzavi), and you can subscribe to our newsletters from the website https://sqlkata.com + +I announce updates on my [Twitter Account](https://twitter.com/ahmadmuzavi), and you can subscribe to our newsletters from the website [https://sqlkata.com](https://sqlkata.com). ### The database that I want is not supported. Why? -It's impossible to support all available database vendors, this is why we focus on the major ones, and we encourage you to create your own compiler for your database. + +It's impossible to support all available database vendors, which is why we focus on the major ones. We encourage you to create your own compiler for your database. ### Do you accept new compilers? -Unfortunately, no, the reason is this will add overhead for the project contributors. We prefer to improve the quality of the existing compilers instead. + +Unfortunately, no. The reason is that this would add overhead for the project contributors. We prefer to improve the quality of the existing compilers instead. ### How can I support the project? -- Star the project here in Github, and share it with your friends -- Follow and upvote it on Product Hunt SqlKata - Dynamic Sql query builder for dotnet | Product Hunt -- You can also donate to support the project financially on open collection. + +- ⭐ Star the project here on GitHub, and share it with your friends. +- 🐱‍💻 Follow and upvote it on Product Hunt: + SqlKata - Dynamic Sql query builder for dotnet | Product Hunt +- 💰 You can also donate to support the project financially on open collection. diff --git a/SqlKata.Execution/SqlKata.Execution.csproj b/SqlKata.Execution/SqlKata.Execution.csproj index f6a7ff1e..b81e1815 100644 --- a/SqlKata.Execution/SqlKata.Execution.csproj +++ b/SqlKata.Execution/SqlKata.Execution.csproj @@ -1,38 +1,32 @@ - - SqlKata The C# Sql Query Builder - Adds the execution capabilities for SqlKata - Ahmad Moussawi - Copyright (c) 2017 Ahmad Moussawi - netstandard2.0 - SqlKata - - - SqlKata.Execution - sql;query-builder;dynamic-query - https://github.com/sqlkata/querybuilder - https://github.com/sqlkata/querybuilder - true - MIT - git - https://github.com/sqlkata/querybuilder - - - true - true - CS1591 - - - bin\Release\netstandard2.0\SqlKata.Execution.xml - - - bin\Debug\netstandard2.0\SqlKata.Execution.xml - - - - - - - - - + + SqlKata + Adds the execution capabilities for SqlKata + Ahmad Moussawi + Copyright (c) 2017 Ahmad Moussawi + net8.0 + SqlKata + + SqlKata.Execution + sql;query-builder;dynamic-query + https://github.com/sqlkata/querybuilder + https://github.com/sqlkata/querybuilder + true + MIT + git + https://github.com/sqlkata/querybuilder + + true + true + CS1591 + + + + + + + + + \ No newline at end of file diff --git a/sqlkata.sln b/sqlkata.sln index 957e67a0..ef91408a 100644 --- a/sqlkata.sln +++ b/sqlkata.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26124.0 @@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QueryBuilder.Tests", "Query EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlKata.Execution", "SqlKata.Execution\SqlKata.Execution.csproj", "{B6DF0569-6040-4EAF-A38B-E4DEB8DC76E0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Program", "Program\Program.csproj", "{5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86D00525-7428-4DD7-914D-0A10D5C53EDE}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig @@ -62,18 +60,6 @@ Global {B6DF0569-6040-4EAF-A38B-E4DEB8DC76E0}.Release|x64.Build.0 = Release|Any CPU {B6DF0569-6040-4EAF-A38B-E4DEB8DC76E0}.Release|x86.ActiveCfg = Release|Any CPU {B6DF0569-6040-4EAF-A38B-E4DEB8DC76E0}.Release|x86.Build.0 = Release|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Debug|x64.ActiveCfg = Debug|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Debug|x64.Build.0 = Debug|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Debug|x86.ActiveCfg = Debug|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Debug|x86.Build.0 = Debug|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Release|Any CPU.Build.0 = Release|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Release|x64.ActiveCfg = Release|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Release|x64.Build.0 = Release|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Release|x86.ActiveCfg = Release|Any CPU - {5DEA7DBC-5B8A-44A9-A070-55E95881A4CF}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE