• 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

0.0
/src/FluentCommand/Query/OrderEntityBuilder.cs
1
using System.Linq.Expressions;
2

3
using FluentCommand.Query.Generators;
4
using FluentCommand.Reflection;
5

6
namespace FluentCommand.Query;
7

8
/// <summary>
9
/// Query order by builder
10
/// </summary>
11
/// <typeparam name="TEntity">The type of the entity.</typeparam>
12
public class OrderEntityBuilder<TEntity> : OrderBuilder<OrderEntityBuilder<TEntity>>
13
    where TEntity : class
14
{
15
    private static readonly TypeAccessor _typeAccessor = TypeAccessor.GetAccessor<TEntity>();
×
16

17
    /// <summary>
18
    /// Initializes a new instance of the <see cref="OrderEntityBuilder{TEntity}"/> class.
19
    /// </summary>
20
    /// <param name="queryGenerator">The query generator.</param>
21
    /// <param name="parameters">The query parameters.</param>
22
    public OrderEntityBuilder(IQueryGenerator queryGenerator, List<QueryParameter> parameters)
23
        : base(queryGenerator, parameters)
×
24
    {
25
    }
×
26

27
    /// <summary>
28
    /// Add an order by clause with the specified property and sort direction.
29
    /// </summary>
30
    /// <typeparam name="TValue">The type of the value.</typeparam>
31
    /// <param name="property">The property.</param>
32
    /// <param name="sortDirection">The sort direction.</param>
33
    /// <returns>
34
    /// The same builder so that multiple calls can be chained.
35
    /// </returns>
36
    public OrderEntityBuilder<TEntity> OrderBy<TValue>(
37
        Expression<Func<TEntity, TValue>> property,
38
        SortDirections sortDirection = SortDirections.Ascending)
39
    {
40
        var propertyAccessor = _typeAccessor.FindProperty(property);
×
41

42
        return OrderBy(propertyAccessor.Column, null, sortDirection);
×
43
    }
44

45
    /// <summary>
46
    /// Add an order by clause with the specified property, sort direction and table alias.
47
    /// </summary>
48
    /// <typeparam name="TValue">The type of the value.</typeparam>
49
    /// <param name="property">The property.</param>
50
    /// <param name="tableAlias">The table alias.</param>
51
    /// <param name="sortDirection">The sort direction.</param>
52
    /// <returns>
53
    /// The same builder so that multiple calls can be chained.
54
    /// </returns>
55
    public OrderEntityBuilder<TEntity> OrderBy<TValue>(
56
        Expression<Func<TEntity, TValue>> property,
57
        string tableAlias,
58
        SortDirections sortDirection = SortDirections.Ascending)
59
    {
60
        var propertyAccessor = _typeAccessor.FindProperty(property);
×
61

62
        return OrderBy(propertyAccessor.Column, tableAlias, sortDirection);
×
63
    }
64

65
    /// <summary>
66
    /// Conditionally add an order by clause with the specified property, sort direction and table alias.
67
    /// </summary>
68
    /// <typeparam name="TValue">The type of the value.</typeparam>
69
    /// <param name="property">The property.</param>
70
    /// <param name="tableAlias">The table alias.</param>
71
    /// <param name="sortDirection">The sort direction.</param>
72
    /// <param name="condition">The condition.</param>
73
    /// <returns>
74
    /// The same builder so that multiple calls can be chained.
75
    /// </returns>
76
    public OrderEntityBuilder<TEntity> OrderByIf<TValue>(
77
        Expression<Func<TEntity, TValue>> property,
78
        string tableAlias = null,
79
        SortDirections sortDirection = SortDirections.Ascending,
80
        Func<string, bool> condition = null)
81
    {
82
        var propertyAccessor = _typeAccessor.FindProperty(property);
×
83

84
        return OrderByIf(propertyAccessor.Column, tableAlias, sortDirection, condition);
×
85
    }
86
}
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