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

loresoft / MediatR.CommandQuery / 11956354083

21 Nov 2024 03:25PM UTC coverage: 60.35% (+1.2%) from 59.17%
11956354083

push

github

pwelter34
add DispatcherDataService

402 of 761 branches covered (52.83%)

Branch coverage included in aggregate %.

64 of 87 new or added lines in 3 files covered. (73.56%)

1 existing line in 1 file now uncovered.

1289 of 2041 relevant lines covered (63.16%)

19.97 hits per line

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

63.33
/src/MediatR.CommandQuery/Queries/EntityFilterBuilder.cs
1

2
using MediatR.CommandQuery.Definitions;
3

4
namespace MediatR.CommandQuery.Queries;
5

6
public static class EntityFilterBuilder
7
{
8
    public static EntityQuery? CreateSearchQuery<TModel>(string searchText, int page = 1, int pageSize = 20)
9
        where TModel : class, ISupportSearch
10
    {
NEW
11
        var filter = CreateSearchFilter<TModel>(searchText);
×
NEW
12
        var sort = CreateSort<TModel>();
×
13

NEW
14
        return new EntityQuery(filter, sort, page, pageSize);
×
15
    }
16

17
    public static EntitySelect? CreateSearchSelect<TModel>(string searchText)
18
        where TModel : class, ISupportSearch
19
    {
NEW
20
        var filter = CreateSearchFilter<TModel>(searchText);
×
NEW
21
        var sort = CreateSort<TModel>();
×
22

NEW
23
        return new EntitySelect(filter, sort);
×
24
    }
25

26
    public static EntityFilter? CreateSearchFilter<TModel>(string searchText)
27
        where TModel : class, ISupportSearch
28
    {
NEW
29
        return CreateSearchFilter(TModel.SearchFields(), searchText);
×
30
    }
31

32

33
    public static EntitySort? CreateSort<TModel>()
34
        where TModel : class, ISupportSearch
35
    {
NEW
36
        return new EntitySort { Name = TModel.SortField() };
×
37
    }
38

39

40
    public static EntityFilter? CreateSearchFilter(IEnumerable<string> fields, string searchText)
41
    {
42
        if (fields is null || string.IsNullOrWhiteSpace(searchText))
2!
NEW
43
            return null;
×
44

45
        var groupFilter = new EntityFilter
2✔
46
        {
2✔
47
            Logic = EntityFilterLogic.Or,
2✔
48
            Filters = [],
2✔
49
        };
2✔
50

51
        foreach (var field in fields)
12✔
52
        {
53
            var filter = new EntityFilter
4✔
54
            {
4✔
55
                Name = field,
4✔
56
                Value = searchText,
4✔
57
                Operator = EntityFilterOperators.Contains,
4✔
58
            };
4✔
59
            groupFilter.Filters.Add(filter);
4✔
60
        }
61

62
        return groupFilter;
2✔
63
    }
64
}
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

© 2025 Coveralls, Inc