private static void FindNavigationProperties(this ODataModelBuilder builder, StructuralTypeConfiguration configuration, IList <Tuple <StructuralTypeConfiguration, IList <MemberInfo>, NavigationPropertyConfiguration> > navs, Stack <MemberInfo> path) { Contract.Assert(builder != null); Contract.Assert(configuration != null); Contract.Assert(navs != null); Contract.Assert(path != null); foreach (var property in configuration.Properties) { path.Push(property.PropertyInfo); NavigationPropertyConfiguration nav = property as NavigationPropertyConfiguration; ComplexPropertyConfiguration complex = property as ComplexPropertyConfiguration; CollectionPropertyConfiguration collection = property as CollectionPropertyConfiguration; if (nav != null) { // how about the containment? IList <MemberInfo> bindingPath = path.Reverse().ToList(); navs.Add( new Tuple <StructuralTypeConfiguration, IList <MemberInfo>, NavigationPropertyConfiguration>(configuration, bindingPath, nav)); } else if (complex != null) { StructuralTypeConfiguration complexType = builder.GetTypeConfigurationOrNull(complex.RelatedClrType) as StructuralTypeConfiguration; builder.FindAllNavigationProperties(complexType, navs, path); } else if (collection != null) { IEdmTypeConfiguration edmType = builder.GetTypeConfigurationOrNull(collection.ElementType); if (edmType != null && edmType.Kind == EdmTypeKind.Complex) { StructuralTypeConfiguration complexType = (StructuralTypeConfiguration)edmType; builder.FindAllNavigationProperties(complexType, navs, path); } } path.Pop(); } }