Skip to content

Commit abbaed2

Browse files
authored
Merge pull request #370 from rtablada/rt/get-context-property
Add 'GetPublicAttributeName' to Context Graph
2 parents 9c54535 + 79fb285 commit abbaed2

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/JsonApiDotNetCore/Internal/ContextGraph.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace JsonApiDotNetCore.Internal
77
public interface IContextGraph
88
{
99
/// <summary>
10-
/// Gets the value of the navigation property, defined by the relationshipName,
10+
/// Gets the value of the navigation property, defined by the relationshipName,
1111
/// on the provided instance.
1212
/// </summary>
1313
/// <param name="resource">The resource instance</param>
@@ -42,6 +42,12 @@ public interface IContextGraph
4242
/// </summary>
4343
ContextEntity GetContextEntity(Type entityType);
4444

45+
/// <summary>
46+
/// Get the public attribute name for a type based on the internal attribute name.
47+
/// </summary>
48+
/// <param name="internalAttributeName">The internal attribute name for a <see cref="Attr" />.</param>
49+
string GetPublicAttributeName<TParent>(string internalAttributeName);
50+
4551
/// <summary>
4652
/// Was built against an EntityFrameworkCore DbContext ?
4753
/// </summary>
@@ -111,5 +117,13 @@ public string GetRelationshipName<TParent>(string relationshipName)
111117
.SingleOrDefault(r => r.Is(relationshipName))
112118
?.InternalRelationshipName;
113119
}
114-
}
120+
121+
public string GetPublicAttributeName<TParent>(string internalAttributeName)
122+
{
123+
return GetContextEntity(typeof(TParent))
124+
.Attributes
125+
.Single(a => a.InternalAttributeName == internalAttributeName)
126+
.PublicAttributeName;
127+
}
128+
}
115129
}

0 commit comments

Comments
 (0)