Skip to content

Commit 3ff2dd8

Browse files
committed
- fixes a null reference exception on implicit nav props detection
1 parent 5e806d9 commit 3ff2dd8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/GraphODataTemplateWriter/Extensions/OdcmModelExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,18 @@ public static OdcmProperty GetServiceCollectionNavigationPropertyForPropertyType
257257
@namespace
258258
.Classes
259259
.Where(odcmClass => odcmClass.Kind == OdcmClassKind.Service)
260-
.First()
261-
.Properties
262-
.Where(property => property.GetType() == typeof(OdcmSingleton)) //Get the list of singletons defined by the service
263-
.Where(singleton => singleton
260+
.FirstOrDefault()
261+
?.Properties
262+
?.Where(property => property.GetType() == typeof(OdcmSingleton)) //Get the list of singletons defined by the service
263+
?.Where(singleton => singleton
264264
.Type
265265
.AsOdcmClass()
266266
.Properties
267267
//Find navigation properties on the singleton that are self-contained (implicit EntitySets) that match the type
268268
//we are searching for
269269
.Where(prop => prop.ContainsTarget == true && prop.Type.Name == odcmProperty.Type.Name)
270270
.FirstOrDefault() != null
271-
)
271+
) ?? new OdcmProperty[] { }
272272
).FirstOrDefault();
273273

274274
if (implicitProperty != null)

0 commit comments

Comments
 (0)