Skip to content

Commit a66534b

Browse files
committed
chore(*): replace Any with Count
1 parent c0e4e6c commit a66534b

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

docs/Usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void Configure(
117117
AppDbContext context)
118118
{
119119
context.Database.EnsureCreated();
120-
if(context.People.Any() == false)
120+
if(context.People.Count == 0)
121121
{
122122
context.People.Add(new Person {
123123
Name = "John Doe"

src/JsonApiDotNetCore/Data/DefaultEntityRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public DefaultEntityRepository(
6262

6363
public virtual IQueryable<TEntity> Get()
6464
{
65-
if (_jsonApiContext.QuerySet?.Fields != null && _jsonApiContext.QuerySet.Fields.Any())
65+
if (_jsonApiContext.QuerySet?.Fields != null && _jsonApiContext.QuerySet.Fields.Count > 0)
6666
return _dbSet.Select(_jsonApiContext.QuerySet?.Fields);
6767

6868
return _dbSet;

src/JsonApiDotNetCore/Extensions/IQueryableExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ public static class IQueryableExtensions
1313
{
1414
public static IOrderedQueryable<TSource> Sort<TSource>(this IQueryable<TSource> source, SortQuery sortQuery)
1515
{
16-
return sortQuery.Direction == SortDirection.Descending
17-
? source.OrderByDescending(sortQuery.SortedAttribute.InternalAttributeName)
16+
return sortQuery.Direction == SortDirection.Descending
17+
? source.OrderByDescending(sortQuery.SortedAttribute.InternalAttributeName)
1818
: source.OrderBy(sortQuery.SortedAttribute.InternalAttributeName);
1919
}
2020

2121
public static IOrderedQueryable<TSource> Sort<TSource>(this IOrderedQueryable<TSource> source, SortQuery sortQuery)
2222
{
23-
return sortQuery.Direction == SortDirection.Descending
24-
? source.ThenByDescending(sortQuery.SortedAttribute.InternalAttributeName)
23+
return sortQuery.Direction == SortDirection.Descending
24+
? source.ThenByDescending(sortQuery.SortedAttribute.InternalAttributeName)
2525
: source.ThenBy(sortQuery.SortedAttribute.InternalAttributeName);
2626
}
2727

@@ -179,7 +179,7 @@ private static Expression GetFilterExpressionLambda(Expression left, Expression
179179

180180
public static IQueryable<TSource> Select<TSource>(this IQueryable<TSource> source, List<string> columns)
181181
{
182-
if (columns == null || columns.Any() == false)
182+
if (columns == null || columns.Count == 0)
183183
return source;
184184

185185
var sourceType = source.ElementType;

src/JsonApiDotNetCore/Services/JsonApiContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public IJsonApiContext ApplyContext<T>(object controller)
6666
var context = _httpContextAccessor.HttpContext;
6767
var path = context.Request.Path.Value.Split('/');
6868

69-
if (context.Request.Query.Any())
69+
if (context.Request.Query.Count > 0)
7070
{
7171
QuerySet = _queryParser.Parse(context.Request.Query);
7272
IncludedRelationships = QuerySet.IncludedRelationships;

0 commit comments

Comments
 (0)