-
-
Notifications
You must be signed in to change notification settings - Fork 513
/
Copy pathJoin.cs
77 lines (66 loc) · 1.89 KB
/
Join.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
namespace SqlKata
{
public class Join : BaseQuery<Join>
{
protected string _type = "inner join";
public string Type
{
get
{
return _type;
}
set
{
_type = value.ToUpperInvariant();
}
}
public Join() : base()
{
}
public override Join Clone()
{
var clone = base.Clone();
clone._type = _type;
return clone;
}
public Join AsType(string type)
{
Type = type;
return this;
}
/// <summary>
/// Alias for "from" operator.
/// Since "from" does not sound well with join clauses
/// </summary>
/// <param name="table"></param>
/// <returns></returns>
public Join JoinWith(string table) => From(table);
public Join JoinWith(Query query) => From(query);
public Join JoinWith(Func<Query, Query> callback) => From(callback);
public Join AsInner() => AsType("inner join");
public Join AsOuter() => AsType("outer join");
public Join AsLeft() => AsType("left join");
public Join AsRight() => AsType("right join");
public Join AsCross() => AsType("cross join");
public Join On(string first, string second, string op = "=")
{
return AddComponent("where", new TwoColumnsCondition
{
First = first,
Second = second,
Operator = op,
IsOr = GetOr(),
IsNot = GetNot()
});
}
public Join OrOn(string first, string second, string op = "=")
{
return Or().On(first, second, op);
}
public override Join NewQuery()
{
return new Join();
}
}
}