Skip to content

Commit 0b005bc

Browse files
committed
- adds the ability to get navigation properties from parent to avoid missing props
1 parent 26e07b0 commit 0b005bc

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/GraphODataTemplateWriter/Extensions/OdcmModelExtensions.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,12 @@ public static bool IsBaseAbstractAndReferencedAsPropertyType(this OdcmClass comp
327327
}
328328
}
329329

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

335338
public static bool IsNavigation(this OdcmProperty property)
@@ -488,14 +491,8 @@ public static List<OdcmMethod> WithDistinctOverloads(this OdcmMethod odcmMethod)
488491
/// Returns a List containing the supplied class' methods plus their overloads
489492
public static List<OdcmMethod> MethodsAndOverloads(this OdcmClass odcmClass)
490493
{
491-
var allMethods = new List<OdcmMethod>();
492-
foreach (var method in odcmClass.Methods)
493-
{
494-
allMethods.AddRange(method.WithOverloads());
495-
}
496-
return allMethods;
494+
return odcmClass.Methods.SelectMany(x => x.WithOverloads()).ToList();
497495
}
498-
499496
}
500497

501498
}

0 commit comments

Comments
 (0)