Skip to content

Commit 93ab64b

Browse files
committed
chore: rename query services, adjustment namespace
1 parent 4525d65 commit 93ab64b

30 files changed

+127
-93
lines changed

src/Examples/JsonApiDotNetCoreExample/Services/CustomArticleService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using JsonApiDotNetCore.Internal.Contracts;
66
using JsonApiDotNetCore.Managers.Contracts;
77
using JsonApiDotNetCore.Models;
8-
using JsonApiDotNetCore.QueryServices.Contracts;
8+
using JsonApiDotNetCore.Query;
99
using JsonApiDotNetCore.Serialization;
1010
using JsonApiDotNetCore.Services;
1111
using JsonApiDotNetCoreExample.Models;

src/JsonApiDotNetCore/Data/DefaultEntityRepository.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public DefaultEntityRepository(
5050
IGenericProcessorFactory genericProcessorFactory,
5151
ResourceDefinition<TEntity> resourceDefinition = null)
5252
{
53-
_logger = loggerFactory.CreateLogger<DefaultEntityRepository<TEntity, TId>>();
53+
_logger = loggerFactory?.CreateLogger<DefaultEntityRepository<TEntity, TId>>();
5454
_targetedFields = updatedFields;
5555
_resourceGraph = resourceGraph;
5656
_genericProcessorFactory = genericProcessorFactory;
@@ -113,10 +113,10 @@ public virtual async Task<TEntity> GetAsync(TId id)
113113
}
114114

115115
/// <inheritdoc />
116-
public virtual async Task<TEntity> GetAndIncludeAsync(TId id, string relationshipName)
116+
public virtual async Task<TEntity> GetAndIncludeAsync(TId id, RelationshipAttribute relationship)
117117
{
118-
_logger?.LogDebug($"[JADN] GetAndIncludeAsync({id}, {relationshipName})");
119-
var includedSet = Include(Select(Get(), _currentRequest.QuerySet?.Fields), relationshipName);
118+
_logger?.LogDebug($"[JADN] GetAndIncludeAsync({id}, {relationship.PublicRelationshipName})");
119+
var includedSet = Include(Select(Get(), _currentRequest.QuerySet?.Fields), relationship);
120120
var result = await includedSet.SingleOrDefaultAsync(e => e.Id.Equals(id));
121121
return result;
122122
}

src/JsonApiDotNetCore/Data/IEntityReadRepository.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Linq;
34
using System.Threading.Tasks;
@@ -33,8 +34,9 @@ public interface IEntityReadRepository<TEntity, in TId>
3334
/// _todoItemsRepository.GetAndIncludeAsync(1, "achieved-date");
3435
/// </code>
3536
/// </example>
36-
IQueryable<TEntity> Include(IQueryable<TEntity> entities, string relationshipName);
3737
IQueryable<TEntity> Include(IQueryable<TEntity> entities, params RelationshipAttribute[] inclusionChain);
38+
[Obsolete]
39+
IQueryable<TEntity> Include(IQueryable<TEntity> entities, string relationshipName);
3840

3941
/// <summary>
4042
/// Apply a filter to the provided queryable
@@ -60,13 +62,13 @@ public interface IEntityReadRepository<TEntity, in TId>
6062
/// Get the entity with the specified id and include the relationship.
6163
/// </summary>
6264
/// <param name="id">The entity id</param>
63-
/// <param name="relationshipName">The exposed relationship name</param>
65+
/// <param name="relationship">The exposed relationship</param>
6466
/// <example>
6567
/// <code>
6668
/// _todoItemsRepository.GetAndIncludeAsync(1, "achieved-date");
6769
/// </code>
6870
/// </example>
69-
Task<TEntity> GetAndIncludeAsync(TId id, string relationshipName);
71+
Task<TEntity> GetAndIncludeAsync(TId id, RelationshipAttribute relationship);
7072

7173
/// <summary>
7274
/// Count the total number of records

src/JsonApiDotNetCore/Extensions/IServiceCollectionExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
using Microsoft.EntityFrameworkCore;
2323
using Microsoft.Extensions.DependencyInjection;
2424
using JsonApiDotNetCore.Internal.Contracts;
25-
using JsonApiDotNetCore.QueryServices.Contracts;
25+
using JsonApiDotNetCore.Query;
2626
using JsonApiDotNetCore.Serialization.Deserializer;
27-
using JsonApiDotNetCore.QueryServices;
27+
using JsonApiDotNetCore.Query;
2828
using JsonApiDotNetCore.Serialization.Server.Builders;
2929
using JsonApiDotNetCore.Serialization.Server;
3030

@@ -224,6 +224,8 @@ public static void AddJsonApiInternals(
224224
services.AddScoped<IFieldsToSerialize, FieldsToSerialize>();
225225
services.AddScoped<IFieldsExplorer, FieldsExplorer>();
226226
services.AddScoped<IOperationsDeserializer, OperationsDeserializer>();
227+
services.AddScoped<ISerializerSettingsProvider, ResponseSerializerSettingsProvider>();
228+
services.AddScoped<IAttributeBehaviourService, AttributeBehaviourService>();
227229

228230
if (jsonApiOptions.EnableResourceHooks)
229231
{

src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,15 @@ public IResourceHookContainer<TEntity> GetResourceHookContainer<TEntity>(Resourc
8181
return (IResourceHookContainer<TEntity>)GetResourceHookContainer(typeof(TEntity), hook);
8282
}
8383

84-
public IEnumerable LoadDbValues(PrincipalType entityTypeForRepository, IEnumerable entities, ResourceHook hook, params RelationshipAttribute[] relationships)
84+
public IEnumerable LoadDbValues(PrincipalType entityTypeForRepository, IEnumerable entities, ResourceHook hook, params RelationshipAttribute[] inclusionChain)
8585
{
86-
var paths = relationships.Select(p => p.RelationshipPath).ToArray();
8786
var idType = TypeHelper.GetIdentifierType(entityTypeForRepository);
8887
var parameterizedGetWhere = GetType()
8988
.GetMethod(nameof(GetWhereAndInclude), BindingFlags.NonPublic | BindingFlags.Instance)
9089
.MakeGenericMethod(entityTypeForRepository, idType);
9190
var casted = ((IEnumerable<object>)entities).Cast<IIdentifiable>();
9291
var ids = casted.Select(e => e.StringId).Cast(idType);
93-
var values = (IEnumerable)parameterizedGetWhere.Invoke(this, new object[] { ids, paths });
92+
var values = (IEnumerable)parameterizedGetWhere.Invoke(this, new object[] { ids, inclusionChain });
9493
if (values == null) return null;
9594
return (IEnumerable)Activator.CreateInstance(typeof(HashSet<>).MakeGenericType(entityTypeForRepository), values.Cast(entityTypeForRepository));
9695
}
@@ -146,15 +145,16 @@ IHooksDiscovery GetHookDiscovery(Type entityType)
146145
return discovery;
147146
}
148147

149-
IEnumerable<TEntity> GetWhereAndInclude<TEntity, TId>(IEnumerable<TId> ids, string[] relationshipPaths) where TEntity : class, IIdentifiable<TId>
148+
IEnumerable<TEntity> GetWhereAndInclude<TEntity, TId>(IEnumerable<TId> ids, RelationshipAttribute[] inclusionChain) where TEntity : class, IIdentifiable<TId>
150149
{
151150
var repo = GetRepository<TEntity, TId>();
152151
var query = repo.Get().Where(e => ids.Contains(e.Id));
153-
foreach (var path in relationshipPaths)
154-
{
155-
query = query.Include(path);
156-
}
157-
return query.ToList();
152+
return repo.Include(query, inclusionChain).ToList();
153+
//foreach (var r in inclusionChain)
154+
//{
155+
// query = query.Include(r);
156+
//}
157+
//return query.ToList();
158158
}
159159

160160
IEntityReadRepository<TEntity, TId> GetRepository<TEntity, TId>() where TEntity : class, IIdentifiable<TId>

src/JsonApiDotNetCore/Hooks/ResourceHookExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
using JsonApiDotNetCore.Extensions;
1111
using JsonApiDotNetCore.Internal.Contracts;
1212
using JsonApiDotNetCore.Serialization;
13-
using JsonApiDotNetCore.QueryServices.Contracts;
13+
using JsonApiDotNetCore.Query;
1414

1515
namespace JsonApiDotNetCore.Hooks
1616
{

src/JsonApiDotNetCore/JsonApiDotNetCore.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@
4646
</ItemGroup>
4747
<ItemGroup>
4848
<Folder Include="Models\JsonApiDocuments\" />
49-
<Folder Include="QueryParameterServices\" />
49+
<Folder Include="Query\" />
5050
<Folder Include="Internal\Exceptions\" />
5151
<Folder Include="Models\Annotation\" />
5252
<Folder Include="Serialization\Common\" />
5353
<Folder Include="Serialization\Client\" />
5454
<Folder Include="Serialization\Server\" />
5555
<Folder Include="Serialization\Server\Builders\" />
56-
<Folder Include="QueryParameterServices\Contracts\" />
57-
<Folder Include="QueryParameterServices\Common\" />
56+
<Folder Include="Query\Contracts\" />
57+
<Folder Include="Query\Common\" />
5858
</ItemGroup>
5959
</Project>

src/JsonApiDotNetCore/Middleware/JsonApiActionFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using JsonApiDotNetCore.Internal;
55
using JsonApiDotNetCore.Internal.Contracts;
66
using JsonApiDotNetCore.Managers.Contracts;
7-
using JsonApiDotNetCore.QueryServices.Contracts;
7+
using JsonApiDotNetCore.Query;
88
using JsonApiDotNetCore.Services;
99
using Microsoft.AspNetCore.Http;
1010
using Microsoft.AspNetCore.Mvc.Filters;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
3+
namespace JsonApiDotNetCore.Query
4+
{
5+
public class AttributeBehaviourService : IAttributeBehaviourService
6+
{
7+
public bool? OmitNullValuedAttributes { get; set; }
8+
public bool? OmitDefaultValuedAttributes { get; set; }
9+
10+
public string Name => throw new NotImplementedException();
11+
12+
public void Parse(string value)
13+
{
14+
throw new NotImplementedException();
15+
}
16+
}
17+
}

src/JsonApiDotNetCore/QueryParameterServices/Common/IQueryParameterService.cs renamed to src/JsonApiDotNetCore/Query/Common/IQueryParameterService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace JsonApiDotNetCore.QueryServices.Contracts
1+
namespace JsonApiDotNetCore.Query
22
{
33
/// <summary>
44
/// Base interface that all query parameter services should inherit.

0 commit comments

Comments
 (0)