-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from json-api-dotnet/develop
#312 Deserializer not linking included relationships
- Loading branch information
Showing
20 changed files
with
407 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/JsonApiDotNetCore/Request/HasOneRelationshipPointers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using JsonApiDotNetCore.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace JsonApiDotNetCore.Request | ||
{ | ||
/// <summary> | ||
/// Stores information to set relationships for the request resource. | ||
/// These relationships must already exist and should not be re-created. | ||
/// | ||
/// The expected use case is POST-ing or PATCH-ing | ||
/// an entity with HasOne relationships: | ||
/// <code> | ||
/// { | ||
/// "data": { | ||
/// "type": "photos", | ||
/// "attributes": { | ||
/// "title": "Ember Hamster", | ||
/// "src": "http://example.com/images/productivity.png" | ||
/// }, | ||
/// "relationships": { | ||
/// "photographer": { | ||
/// "data": { "type": "people", "id": "2" } | ||
/// } | ||
/// } | ||
/// } | ||
/// } | ||
/// </code> | ||
/// </summary> | ||
public class HasOneRelationshipPointers | ||
{ | ||
private Dictionary<Type, IIdentifiable> _hasOneRelationships = new Dictionary<Type, IIdentifiable>(); | ||
|
||
/// <summary> | ||
/// Add the relationship to the list of relationships that should be | ||
/// set in the repository layer. | ||
/// </summary> | ||
public void Add(Type dependentType, IIdentifiable entity) | ||
=> _hasOneRelationships[dependentType] = entity; | ||
|
||
/// <summary> | ||
/// Get all the models that should be associated | ||
/// </summary> | ||
public Dictionary<Type, IIdentifiable> Get() => _hasOneRelationships; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.