Skip to content

Commit b562548

Browse files
MilosMilos
Milos
authored and
Milos
committed
GetQueryable revert to Get()
1 parent 7cb3fbd commit b562548

File tree

4 files changed

+7
-20
lines changed

4 files changed

+7
-20
lines changed

src/JsonApiDotNetCore/Data/DefaultEntityRepository.cs

+3-13
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,8 @@ public DefaultEntityRepository(
7878
_resourceDefinition = resourceDefinition;
7979
}
8080

81-
82-
83-
public virtual IQueryable<TEntity> Get()
84-
{
85-
if (_jsonApiContext.QuerySet?.Fields != null && _jsonApiContext.QuerySet.Fields.Count > 0)
86-
return _dbSet.Select(_jsonApiContext.QuerySet?.Fields);
87-
88-
return _dbSet;
89-
}
90-
9181
/// <inheritdoc />
92-
public virtual IQueryable<TEntity> GetQueryable()
82+
public virtual IQueryable<TEntity> Get()
9383
=> _dbSet;
9484

9585
public virtual IQueryable<TEntity> Select(IQueryable<TEntity> entities, List<string> fields)
@@ -140,15 +130,15 @@ public virtual IQueryable<TEntity> Sort(IQueryable<TEntity> entities, List<SortQ
140130
/// <inheritdoc />
141131
public virtual async Task<TEntity> GetAsync(TId id)
142132
{
143-
return await Select(GetQueryable(), _jsonApiContext.QuerySet?.Fields).SingleOrDefaultAsync(e => e.Id.Equals(id));
133+
return await Select(Get(), _jsonApiContext.QuerySet?.Fields).SingleOrDefaultAsync(e => e.Id.Equals(id));
144134
}
145135

146136
/// <inheritdoc />
147137
public virtual async Task<TEntity> GetAndIncludeAsync(TId id, string relationshipName)
148138
{
149139
_logger?.LogDebug($"[JADN] GetAndIncludeAsync({id}, {relationshipName})");
150140

151-
var includedSet = Include(Select(GetQueryable(), _jsonApiContext.QuerySet?.Fields), relationshipName);
141+
var includedSet = Include(Select(Get(), _jsonApiContext.QuerySet?.Fields), relationshipName);
152142
var result = await includedSet.SingleOrDefaultAsync(e => e.Id.Equals(id));
153143

154144
return result;

src/JsonApiDotNetCore/Data/IEntityReadRepository.cs

-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ public interface IEntityReadRepository<TEntity, in TId>
1919
/// The base GET query. This is a good place to apply rules that should affect all reads,
2020
/// such as authorization of resources.
2121
/// </summary>
22-
IQueryable<TEntity> GetQueryable();
23-
24-
[Obsolete("This method has been deprecated, use GetQueryable() instead")]
2522
IQueryable<TEntity> Get();
2623

2724
/// <summary>

src/JsonApiDotNetCore/Services/EntityResourceService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public virtual async Task<bool> DeleteAsync(TId id)
9898

9999
public virtual async Task<IEnumerable<TResource>> GetAsync()
100100
{
101-
var entities = _entities.GetQueryable();
101+
var entities = _entities.Get();
102102

103103
entities = ApplySortAndFilterQuery(entities);
104104

@@ -242,7 +242,7 @@ protected virtual IQueryable<TEntity> IncludeRelationships(IQueryable<TEntity> e
242242

243243
private async Task<TResource> GetWithRelationshipsAsync(TId id)
244244
{
245-
var query = _entities.Select(_entities.GetQueryable(), _jsonApiContext.QuerySet?.Fields).Where(e => e.Id.Equals(id));
245+
var query = _entities.Select(_entities.Get(), _jsonApiContext.QuerySet?.Fields).Where(e => e.Id.Equals(id));
246246

247247
_jsonApiContext.QuerySet.IncludedRelationships.ForEach(r =>
248248
{

test/JsonApiDotNetCoreExampleTests/Helpers/Repositories/AuthorizedTodoItemsRepository.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public AuthorizedTodoItemsRepository(
2323
_authService = authService;
2424
}
2525

26-
public override IQueryable<TodoItem> GetQueryable()
26+
public override IQueryable<TodoItem> Get()
2727
{
28-
return base.GetQueryable().Where(todoItem => todoItem.OwnerId == _authService.CurrentUserId);
28+
return base.Get().Where(todoItem => todoItem.OwnerId == _authService.CurrentUserId);
2929
}
3030
}
3131
}

0 commit comments

Comments
 (0)