forked from sqlkata/querybuilder
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure all files have consistent line-endings.
- Loading branch information
1 parent
c466c24
commit ba004eb
Showing
31 changed files
with
346 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
parameters: | ||
- name: project | ||
type: string | ||
default: # Empty | ||
- name: configuration | ||
type: string | ||
default: # Empty | ||
- name: packageVersion | ||
type: string | ||
default: # Empty | ||
- name: outputDir | ||
type: string | ||
default: # Empty | ||
|
||
|
||
steps: | ||
- template: check.missing.parameters.yml | ||
|
||
- task: DotNetCoreCLI@2 | ||
displayName: Package ${{ parameters.project }} | ||
inputs: | ||
command: custom # such convenience, much easy | ||
custom: pack | ||
arguments: ${{ parameters.project }} --verbosity Detailed --configuration ${{ parameters.configuration }} --output ${{ parameters.outputDir }} --no-build --no-restore --include-source --include-symbols -p:SymbolPackageFormat=snupkg -p:PackageVersion=${{ parameters.packageVersion }} | ||
nobuild: true # ... None ... | ||
includesource: true # ... of ... | ||
includesymbols: true # ... these ... | ||
outputDir: ${{ parameters.outputDir }} # ... do ... | ||
packagesToPack: ${{ parameters.project }} # ... anything. ... | ||
parameters: | ||
- name: project | ||
type: string | ||
default: # Empty | ||
- name: configuration | ||
type: string | ||
default: # Empty | ||
- name: packageVersion | ||
type: string | ||
default: # Empty | ||
- name: outputDir | ||
type: string | ||
default: # Empty | ||
|
||
|
||
steps: | ||
- template: check.missing.parameters.yml | ||
|
||
- task: DotNetCoreCLI@2 | ||
displayName: Package ${{ parameters.project }} | ||
inputs: | ||
command: custom # such convenience, much easy | ||
custom: pack | ||
arguments: ${{ parameters.project }} --verbosity Detailed --configuration ${{ parameters.configuration }} --output ${{ parameters.outputDir }} --no-build --no-restore --include-source --include-symbols -p:SymbolPackageFormat=snupkg -p:PackageVersion=${{ parameters.packageVersion }} | ||
nobuild: true # ... None ... | ||
includesource: true # ... of ... | ||
includesymbols: true # ... these ... | ||
outputDir: ${{ parameters.outputDir }} # ... do ... | ||
packagesToPack: ${{ parameters.project }} # ... anything. ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
# Modelled after https://github.com/UiPath/ServiceCommon/blob/3f7b73831b9ac4106ad89e036c955220f96f5eb3/Ledger/.vsts-ci.yml | ||
|
||
parameters: | ||
- name: environment | ||
type: string | ||
default: # Empty, to force people to think about this | ||
- name: feed | ||
type: string | ||
default: # Empty, to force people to think about this | ||
- name: version | ||
type: string | ||
default: # Empty, to force people to think about this | ||
- name: condition | ||
type: string | ||
default: # Empty, to force people to think about this | ||
- name: dependsOn | ||
type: object | ||
default: # Empty, to force people to think about this | ||
|
||
|
||
stages: | ||
- stage: PublishTo${{ replace(parameters.environment, '-', '') }} | ||
displayName: Publish packages to ${{ parameters.environment }} feed | ||
dependsOn: | ||
${{ parameters.dependsOn }} | ||
condition: and(succeeded(), ${{ parameters.condition }}) | ||
jobs: | ||
- deployment: | ||
environment: ${{ parameters.environment }} | ||
workspace: | ||
clean: all | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- checkout: none | ||
|
||
- template: check.missing.parameters.yml | ||
|
||
- task: Bash@3 | ||
displayName: Set version number environment variable | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
echo "setting version to '${{ parameters.version }}'" | ||
echo "##vso[task.setvariable variable=NuGetVerionEnvVar]${{ parameters.version }}" | ||
- task: NuGetCommand@2 | ||
inputs: | ||
command: push | ||
versioningScheme: byEnvVar | ||
versionEnvVar: NuGetVerionEnvVar | ||
packagesToPush: $(Pipeline.Workspace)/**/*.nupkg | ||
publishVstsFeed: ${{ parameters.feed }} | ||
# Modelled after https://github.com/UiPath/ServiceCommon/blob/3f7b73831b9ac4106ad89e036c955220f96f5eb3/Ledger/.vsts-ci.yml | ||
|
||
parameters: | ||
- name: environment | ||
type: string | ||
default: # Empty, to force people to think about this | ||
- name: feed | ||
type: string | ||
default: # Empty, to force people to think about this | ||
- name: version | ||
type: string | ||
default: # Empty, to force people to think about this | ||
- name: condition | ||
type: string | ||
default: # Empty, to force people to think about this | ||
- name: dependsOn | ||
type: object | ||
default: # Empty, to force people to think about this | ||
|
||
|
||
stages: | ||
- stage: PublishTo${{ replace(parameters.environment, '-', '') }} | ||
displayName: Publish packages to ${{ parameters.environment }} feed | ||
dependsOn: | ||
${{ parameters.dependsOn }} | ||
condition: and(succeeded(), ${{ parameters.condition }}) | ||
jobs: | ||
- deployment: | ||
environment: ${{ parameters.environment }} | ||
workspace: | ||
clean: all | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- checkout: none | ||
|
||
- template: check.missing.parameters.yml | ||
|
||
- task: Bash@3 | ||
displayName: Set version number environment variable | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
echo "setting version to '${{ parameters.version }}'" | ||
echo "##vso[task.setvariable variable=NuGetVerionEnvVar]${{ parameters.version }}" | ||
- task: NuGetCommand@2 | ||
inputs: | ||
command: push | ||
versioningScheme: byEnvVar | ||
versionEnvVar: NuGetVerionEnvVar | ||
packagesToPush: $(Pipeline.Workspace)/**/*.nupkg | ||
publishVstsFeed: ${{ parameters.feed }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,114 @@ | ||
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<Installment> Installments { get; set; } = new List<Installment>(); | ||
} | ||
|
||
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; | ||
} | ||
|
||
} | ||
} | ||
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<Installment> Installments { get; set; } = new List<Installment>(); | ||
} | ||
|
||
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; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.