From 79fb2856af7f9b475396f7dbcff31eb37be660a4 Mon Sep 17 00:00:00 2001 From: Ryan Tablada Date: Tue, 7 Aug 2018 17:20:06 -0500 Subject: [PATCH] feat: add 'GetPublicAttributeName' to ContextGraph --- src/JsonApiDotNetCore/Internal/ContextGraph.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/JsonApiDotNetCore/Internal/ContextGraph.cs b/src/JsonApiDotNetCore/Internal/ContextGraph.cs index c0c7f2274b..6a39a292de 100644 --- a/src/JsonApiDotNetCore/Internal/ContextGraph.cs +++ b/src/JsonApiDotNetCore/Internal/ContextGraph.cs @@ -7,7 +7,7 @@ namespace JsonApiDotNetCore.Internal public interface IContextGraph { /// - /// Gets the value of the navigation property, defined by the relationshipName, + /// Gets the value of the navigation property, defined by the relationshipName, /// on the provided instance. /// /// The resource instance @@ -42,6 +42,12 @@ public interface IContextGraph /// ContextEntity GetContextEntity(Type entityType); + /// + /// Get the public attribute name for a type based on the internal attribute name. + /// + /// The internal attribute name for a . + string GetPublicAttributeName(string internalAttributeName); + /// /// Was built against an EntityFrameworkCore DbContext ? /// @@ -111,5 +117,13 @@ public string GetRelationshipName(string relationshipName) .SingleOrDefault(r => r.Is(relationshipName)) ?.InternalRelationshipName; } - } + + public string GetPublicAttributeName(string internalAttributeName) + { + return GetContextEntity(typeof(TParent)) + .Attributes + .Single(a => a.InternalAttributeName == internalAttributeName) + .PublicAttributeName; + } + } }