Skip to content

Commit f73e84f

Browse files
committed
- adds missing navigation properties from uppermost parents
1 parent cf7fa35 commit f73e84f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/GraphODataTemplateWriter/Extensions/OdcmModelExtensions.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ public static IEnumerable<OdcmMethod> GetMethods(this OdcmModel model)
149149
/// <param name="host">The T4Host that orchestrates applying templates to the OdcmModel.</param>
150150
/// <returns>A boolean value that indicates whether the current type needs to be disambiguated.</returns>
151151
public static bool DoesCurrentTypeNeedDisambiguation(this CustomT4Host host)
152-
{
152+
{
153153
// At this point this is only applicable to OdcmProperty.
154154
// Challenging this assumption will require a lot more investigation.
155155
if (!(host.CurrentType is OdcmProperty))
156-
return false;
156+
return false;
157157

158158
// We only support "Request" dismabiguation at this point. Check whether the
159159
// current type ends in "Request".
@@ -278,7 +278,8 @@ public static OdcmProperty GetServiceCollectionNavigationPropertyForPropertyType
278278
//as an exception so the service has an opportunity to correct this in the metadata
279279
throw new Exception("Found no valid EntitySet for the given property.");
280280

281-
} catch (Exception e)
281+
}
282+
catch (Exception e)
282283
{
283284
logger.Error("The navigation property \"{0}\" on class \"{1}\" does not specify it is self-contained nor is it defined in an explicit or implicit EntitySet", odcmProperty.Name.ToString(), odcmProperty.Class.FullName.ToString());
284285
logger.Error(e);
@@ -327,10 +328,11 @@ public static bool IsBaseAbstractAndReferencedAsPropertyType(this OdcmClass comp
327328

328329
public static IEnumerable<OdcmProperty> NavigationProperties(this OdcmClass odcmClass, bool includeBaseProperties = false)
329330
{
330-
return odcmClass.Properties.Where(prop => prop.IsNavigation())
331-
.Union(includeBaseProperties && odcmClass.Base != null ?
332-
odcmClass.Base.Properties.Where(x => x.IsNavigation()) :
333-
new List<OdcmProperty>());
331+
if (includeBaseProperties && odcmClass.Base != null)
332+
return odcmClass.Base.NavigationProperties(includeBaseProperties)
333+
.Union(odcmClass.Properties.Where(prop => prop.IsNavigation()));
334+
else
335+
return odcmClass.Properties.Where(prop => prop.IsNavigation());
334336
}
335337

336338
public static bool IsNavigation(this OdcmProperty property)

0 commit comments

Comments
 (0)