• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / FluentCommand / 6648415992

26 Oct 2023 01:49AM UTC coverage: 51.645% (+0.1%) from 51.515%
6648415992

push

github

pwelter34
Update InsertBuilder.cs

981 of 2442 branches covered (0.0%)

Branch coverage included in aggregate %.

2896 of 5065 relevant lines covered (57.18%)

156.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.66
/src/FluentCommand/Query/JoinBuilder.cs
1
using FluentCommand.Query.Generators;
2

3
namespace FluentCommand.Query;
4

5
/// <summary>
6
/// Join clause builder
7
/// </summary>
8
public class JoinBuilder : JoinBuilder<JoinBuilder>
9
{
10
    /// <summary>
11
    /// Initializes a new instance of the <see cref="JoinBuilder"/> class.
12
    /// </summary>
13
    /// <param name="queryGenerator">The query generator.</param>
14
    /// <param name="parameters">The query parameters.</param>
15
    public JoinBuilder(IQueryGenerator queryGenerator, List<QueryParameter> parameters)
16
        : base(queryGenerator, parameters)
1✔
17
    {
18
    }
1✔
19
}
20

21
/// <summary>
22
/// 
23
/// </summary>
24
/// <typeparam name="TBuilder">The type of the builder.</typeparam>
25
public class JoinBuilder<TBuilder> : StatementBuilder<TBuilder>
26
    where TBuilder : JoinBuilder<TBuilder>
27
{
28
    /// <summary>
29
    /// Initializes a new instance of the <see cref="JoinBuilder{TBuilder}"/> class.
30
    /// </summary>
31
    /// <param name="queryGenerator">The query generator.</param>
32
    /// <param name="parameters">The query parameters.</param>
33
    public JoinBuilder(IQueryGenerator queryGenerator, List<QueryParameter> parameters)
34
        : base(queryGenerator, parameters)
13✔
35
    {
36
    }
13✔
37

38
    /// <summary>
39
    /// Gets or sets the join expression.
40
    /// </summary>
41
    /// <value>
42
    /// The join expression.
43
    /// </value>
44
    protected JoinExpression JoinExpression { get; set; } = new();
13✔
45

46
    /// <summary>
47
    /// The left column to join on.
48
    /// </summary>
49
    /// <param name="columnName">Name of the column.</param>
50
    /// <param name="tableAlias">The table alias.</param>
51
    /// <returns>
52
    /// The same builder so that multiple calls can be chained.
53
    /// </returns>
54
    public TBuilder Left(
55
        string columnName,
56
        string tableAlias)
57
    {
58
        JoinExpression = JoinExpression with
13✔
59
        {
13✔
60
            LeftColumnName = columnName,
13✔
61
            LeftTableAlias = tableAlias
13✔
62
        };
13✔
63

64
        return (TBuilder)this;
13✔
65
    }
66

67
    /// <summary>
68
    /// The right column to join on.
69
    /// </summary>
70
    /// <param name="columnName">Name of the column.</param>
71
    /// <param name="tableName">Name of the table.</param>
72
    /// <param name="tableSchema">The table schema.</param>
73
    /// <param name="tableAlias">The table alias.</param>
74
    /// <returns>
75
    /// The same builder so that multiple calls can be chained.
76
    /// </returns>
77
    public TBuilder Right(
78
        string columnName,
79
        string tableName,
80
        string tableSchema,
81
        string tableAlias)
82
    {
83
        JoinExpression = JoinExpression with
13!
84
        {
13✔
85
            RightColumnName = columnName,
13✔
86
            RightTableName = tableName,
13✔
87
            RightTableSchema = tableSchema,
13✔
88
            RightTableAlias = tableAlias ?? tableName
13✔
89
        };
13✔
90

91
        return (TBuilder)this;
13✔
92
    }
93

94
    /// <summary>
95
    /// Specify the join type.
96
    /// </summary>
97
    /// <param name="joinType">Type of the join.</param>
98
    /// <returns>
99
    /// The same builder so that multiple calls can be chained.
100
    /// </returns>
101
    public TBuilder Type(JoinTypes joinType)
102
    {
103
        JoinExpression = JoinExpression with
1✔
104
        {
1✔
105
            JoinType = joinType
1✔
106
        };
1✔
107

108
        return (TBuilder)this;
1✔
109
    }
110

111
    /// <summary>
112
    /// Builds the join expression.
113
    /// </summary>
114
    /// <returns>
115
    /// The same builder so that multiple calls can be chained.
116
    /// </returns>
117
    public virtual JoinExpression BuildExpression()
118
    {
119
        return JoinExpression;
13✔
120
    }
121

122
    /// <inheritdoc />
123
    public override QueryStatement BuildStatement()
124
    {
125
        var joinClause = QueryGenerator.JoinExpression(JoinExpression);
×
126

127
        return new QueryStatement(joinClause, Parameters);
×
128
    }
129
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc