4
4
namespace JsonApiDotNetCore . Models
5
5
{
6
6
/// <summary>
7
- ///
7
+ /// Create a HasMany relationship through a many-to-many join relationship.
8
8
/// </summary>
9
9
///
10
10
/// <example>
11
- ///
11
+ /// In the following example, we expose a relationship named "tags"
12
+ /// through the navigation property `ArticleTags`.
13
+ /// The `Tags` property is decorated as `NotMapped` so that EF does not try
14
+ /// to map this to a database relationship.
15
+ /// <code>
16
+ /// [NotMapped]
17
+ /// [HasManyThrough("tags", nameof(ArticleTags))]
18
+ /// public List<Tag> Tags { get; set; }
19
+ /// public List<ArticleTag> ArticleTags { get; set; }
20
+ /// </code>
12
21
/// </example>
13
22
public class HasManyThroughAttribute : HasManyAttribute
14
23
{
15
24
/// <summary>
16
- ///
25
+ /// Create a HasMany relationship through a many-to-many join relationship.
26
+ /// The public name exposed through the API will be based on the configured convention.
17
27
/// </summary>
18
28
///
19
- /// <param name="publicName">The relationship name as exposed by the API</param>
20
29
/// <param name="internalThroughName">The name of the navigation property that will be used to get the HasMany relationship</param>
21
30
/// <param name="documentLinks">Which links are available. Defaults to <see cref="Link.All"/></param>
22
31
/// <param name="canInclude">Whether or not this relationship can be included using the <c>?include=public-name</c> query string</param>
23
32
///
24
33
/// <example>
25
- ///
34
+ /// <code>
35
+ /// [HasManyThrough(nameof(ArticleTags), documentLinks: Link.All, canInclude: true)]
36
+ /// </code>
26
37
/// </example>
27
38
public HasManyThroughAttribute ( string internalThroughName , Link documentLinks = Link . All , bool canInclude = true )
28
39
: base ( null , documentLinks , canInclude )
@@ -31,7 +42,7 @@ public HasManyThroughAttribute(string internalThroughName, Link documentLinks =
31
42
}
32
43
33
44
/// <summary>
34
- ///
45
+ /// Create a HasMany relationship through a many-to-many join relationship.
35
46
/// </summary>
36
47
///
37
48
/// <param name="publicName">The relationship name as exposed by the API</param>
@@ -40,19 +51,36 @@ public HasManyThroughAttribute(string internalThroughName, Link documentLinks =
40
51
/// <param name="canInclude">Whether or not this relationship can be included using the <c>?include=public-name</c> query string</param>
41
52
///
42
53
/// <example>
43
- ///
54
+ /// <code>
55
+ /// [HasManyThrough("tags", nameof(ArticleTags), documentLinks: Link.All, canInclude: true)]
56
+ /// </code>
44
57
/// </example>
45
58
public HasManyThroughAttribute ( string publicName , string internalThroughName , Link documentLinks = Link . All , bool canInclude = true )
46
59
: base ( publicName , documentLinks , canInclude )
47
60
{
48
61
InternalThroughName = internalThroughName ;
49
62
}
50
63
64
+ /// <summary>
65
+ /// The name of the join property on the parent resource.
66
+ /// </summary>
67
+ /// <example>
68
+ /// In the `[HasManyThrough("tags", nameof(ArticleTags))]` example
69
+ /// this would be "ArticleTags".
70
+ /// </example>
51
71
public string InternalThroughName { get ; private set ; }
72
+
73
+ /// <summary>
74
+ /// The join type.
75
+ /// </summary>
76
+ /// <example>
77
+ /// In the `[HasManyThrough("tags", nameof(ArticleTags))]` example
78
+ /// this would be `ArticleTag`.
79
+ /// </example>
52
80
public Type ThroughType { get ; internal set ; }
53
81
54
82
/// <summary>
55
- /// The navigation property back to the parent resource.
83
+ /// The navigation property back to the parent resource from the join type .
56
84
/// </summary>
57
85
///
58
86
/// <example>
@@ -67,7 +95,7 @@ public HasManyThroughAttribute(string publicName, string internalThroughName, Li
67
95
public PropertyInfo LeftProperty { get ; internal set ; }
68
96
69
97
/// <summary>
70
- /// The navigation property to the related resource.
98
+ /// The navigation property to the related resource from the join type .
71
99
/// </summary>
72
100
///
73
101
/// <example>
0 commit comments