Skip to content

Commit e72b97b

Browse files
Ensure all files have consistent line-endings.
1 parent cf7a14a commit e72b97b

File tree

3 files changed

+235
-235
lines changed

3 files changed

+235
-235
lines changed

Program/Program.cs

Lines changed: 114 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,114 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using SqlKata;
4-
using SqlKata.Compilers;
5-
using SqlKata.Execution;
6-
using System.Data.SqlClient;
7-
using System.Threading.Tasks;
8-
using System.Linq;
9-
using Newtonsoft.Json;
10-
using Npgsql;
11-
using System.Data;
12-
using Dapper;
13-
using System.Data.SQLite;
14-
using static SqlKata.Expressions;
15-
using System.IO;
16-
17-
namespace Program
18-
{
19-
class Program
20-
{
21-
private class Loan
22-
{
23-
public string Id { get; set; }
24-
public string Name { get; set; }
25-
public List<Installment> Installments { get; set; } = new List<Installment>();
26-
}
27-
28-
private class Installment
29-
{
30-
public string Id { get; set; }
31-
public string LoanId { get; set; }
32-
public int DaysCount { get; set; }
33-
}
34-
35-
static void Main(string[] args)
36-
{
37-
using (var db = SqlLiteQueryFactory())
38-
{
39-
var query = db.Query("accounts")
40-
.Where("balance", ">", 0)
41-
.GroupBy("balance")
42-
.Limit(10);
43-
44-
var accounts = query.Clone().Get();
45-
Console.WriteLine(JsonConvert.SerializeObject(accounts, Formatting.Indented));
46-
47-
var exists = query.Clone().Exists();
48-
Console.WriteLine(exists);
49-
}
50-
}
51-
52-
private static void log(Compiler compiler, Query query)
53-
{
54-
var compiled = compiler.Compile(query);
55-
Console.WriteLine(compiled.ToString());
56-
Console.WriteLine(JsonConvert.SerializeObject(compiled.Bindings));
57-
}
58-
59-
private static QueryFactory SqlLiteQueryFactory()
60-
{
61-
var compiler = new SqliteCompiler();
62-
63-
var connection = new SQLiteConnection("Data Source=Demo.db");
64-
65-
var db = new QueryFactory(connection, compiler);
66-
67-
db.Logger = result =>
68-
{
69-
Console.WriteLine(result.ToString());
70-
};
71-
72-
if (!File.Exists("Demo.db"))
73-
{
74-
Console.WriteLine("db not exists creating db");
75-
76-
SQLiteConnection.CreateFile("Demo.db");
77-
78-
db.Statement("create table accounts(id integer primary key autoincrement, name varchar, currency_id varchar, balance decimal, created_at datetime);");
79-
for (var i = 0; i < 10; i++)
80-
{
81-
db.Statement("insert into accounts(name, currency_id, balance, created_at) values(@name, @currency, @balance, @date)", new
82-
{
83-
name = $"Account {i}",
84-
currency = "USD",
85-
balance = 100 * i * 1.1,
86-
date = DateTime.UtcNow,
87-
});
88-
}
89-
90-
}
91-
92-
return db;
93-
94-
}
95-
96-
private static QueryFactory SqlServerQueryFactory()
97-
{
98-
var compiler = new PostgresCompiler();
99-
var connection = new SqlConnection(
100-
"Server=tcp:localhost,1433;Initial Catalog=Lite;User ID=sa;Password=P@ssw0rd"
101-
);
102-
103-
var db = new QueryFactory(connection, compiler);
104-
105-
db.Logger = result =>
106-
{
107-
Console.WriteLine(result.ToString());
108-
};
109-
110-
return db;
111-
}
112-
113-
}
114-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using SqlKata;
4+
using SqlKata.Compilers;
5+
using SqlKata.Execution;
6+
using System.Data.SqlClient;
7+
using System.Threading.Tasks;
8+
using System.Linq;
9+
using Newtonsoft.Json;
10+
using Npgsql;
11+
using System.Data;
12+
using Dapper;
13+
using System.Data.SQLite;
14+
using static SqlKata.Expressions;
15+
using System.IO;
16+
17+
namespace Program
18+
{
19+
class Program
20+
{
21+
private class Loan
22+
{
23+
public string Id { get; set; }
24+
public string Name { get; set; }
25+
public List<Installment> Installments { get; set; } = new List<Installment>();
26+
}
27+
28+
private class Installment
29+
{
30+
public string Id { get; set; }
31+
public string LoanId { get; set; }
32+
public int DaysCount { get; set; }
33+
}
34+
35+
static void Main(string[] args)
36+
{
37+
using (var db = SqlLiteQueryFactory())
38+
{
39+
var query = db.Query("accounts")
40+
.Where("balance", ">", 0)
41+
.GroupBy("balance")
42+
.Limit(10);
43+
44+
var accounts = query.Clone().Get();
45+
Console.WriteLine(JsonConvert.SerializeObject(accounts, Formatting.Indented));
46+
47+
var exists = query.Clone().Exists();
48+
Console.WriteLine(exists);
49+
}
50+
}
51+
52+
private static void log(Compiler compiler, Query query)
53+
{
54+
var compiled = compiler.Compile(query);
55+
Console.WriteLine(compiled.ToString());
56+
Console.WriteLine(JsonConvert.SerializeObject(compiled.Bindings));
57+
}
58+
59+
private static QueryFactory SqlLiteQueryFactory()
60+
{
61+
var compiler = new SqliteCompiler();
62+
63+
var connection = new SQLiteConnection("Data Source=Demo.db");
64+
65+
var db = new QueryFactory(connection, compiler);
66+
67+
db.Logger = result =>
68+
{
69+
Console.WriteLine(result.ToString());
70+
};
71+
72+
if (!File.Exists("Demo.db"))
73+
{
74+
Console.WriteLine("db not exists creating db");
75+
76+
SQLiteConnection.CreateFile("Demo.db");
77+
78+
db.Statement("create table accounts(id integer primary key autoincrement, name varchar, currency_id varchar, balance decimal, created_at datetime);");
79+
for (var i = 0; i < 10; i++)
80+
{
81+
db.Statement("insert into accounts(name, currency_id, balance, created_at) values(@name, @currency, @balance, @date)", new
82+
{
83+
name = $"Account {i}",
84+
currency = "USD",
85+
balance = 100 * i * 1.1,
86+
date = DateTime.UtcNow,
87+
});
88+
}
89+
90+
}
91+
92+
return db;
93+
94+
}
95+
96+
private static QueryFactory SqlServerQueryFactory()
97+
{
98+
var compiler = new PostgresCompiler();
99+
var connection = new SqlConnection(
100+
"Server=tcp:localhost,1433;Initial Catalog=Lite;User ID=sa;Password=P@ssw0rd"
101+
);
102+
103+
var db = new QueryFactory(connection, compiler);
104+
105+
db.Logger = result =>
106+
{
107+
Console.WriteLine(result.ToString());
108+
};
109+
110+
return db;
111+
}
112+
113+
}
114+
}

SqlKata.Execution/XQuery.cs

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
using System;
2-
using System.Data;
3-
using System.Linq;
4-
using SqlKata.Compilers;
5-
6-
namespace SqlKata.Execution
7-
{
8-
public class XQuery : Query
9-
{
10-
public IDbConnection Connection { get; set; }
11-
public Compiler Compiler { get; set; }
12-
public Action<SqlResult> Logger = result => { };
13-
public QueryFactory QueryFactory { get; set; }
14-
15-
public XQuery(IDbConnection connection, Compiler compiler)
16-
{
17-
this.Connection = connection;
18-
this.Compiler = compiler;
19-
}
20-
21-
public override Query Clone()
22-
{
23-
24-
var query = new XQuery(this.Connection, this.Compiler);
25-
26-
query.Clauses = this.Clauses.Select(x => x.Clone()).ToList();
27-
query.Logger = this.Logger;
28-
29-
query.QueryAlias = QueryAlias;
30-
query.IsDistinct = IsDistinct;
31-
query.Method = Method;
32-
query.Includes = Includes;
33-
query.Variables = Variables;
34-
35-
query.SetEngineScope(EngineScope);
36-
37-
return query;
38-
}
39-
40-
}
41-
42-
}
1+
using System;
2+
using System.Data;
3+
using System.Linq;
4+
using SqlKata.Compilers;
5+
6+
namespace SqlKata.Execution
7+
{
8+
public class XQuery : Query
9+
{
10+
public IDbConnection Connection { get; set; }
11+
public Compiler Compiler { get; set; }
12+
public Action<SqlResult> Logger = result => { };
13+
public QueryFactory QueryFactory { get; set; }
14+
15+
public XQuery(IDbConnection connection, Compiler compiler)
16+
{
17+
this.Connection = connection;
18+
this.Compiler = compiler;
19+
}
20+
21+
public override Query Clone()
22+
{
23+
24+
var query = new XQuery(this.Connection, this.Compiler);
25+
26+
query.Clauses = this.Clauses.Select(x => x.Clone()).ToList();
27+
query.Logger = this.Logger;
28+
29+
query.QueryAlias = QueryAlias;
30+
query.IsDistinct = IsDistinct;
31+
query.Method = Method;
32+
query.Includes = Includes;
33+
query.Variables = Variables;
34+
35+
query.SetEngineScope(EngineScope);
36+
37+
return query;
38+
}
39+
40+
}
41+
42+
}

0 commit comments

Comments
 (0)