public static IEnumerable <ComplexTypeConfiguration> DerivedTypes(this ODataModelBuilder modelBuilder, ComplexTypeConfiguration complex) { if (modelBuilder == null) { throw Error.ArgumentNull("modelBuilder"); } if (complex == null) { throw Error.ArgumentNull("complex"); } IEnumerable <ComplexTypeConfiguration> derivedComplexs = modelBuilder.StructuralTypes.OfType <ComplexTypeConfiguration>().Where(e => e.BaseType == complex); foreach (ComplexTypeConfiguration derivedType in derivedComplexs) { yield return(derivedType); foreach (ComplexTypeConfiguration derivedDerivedType in modelBuilder.DerivedTypes(derivedType)) { yield return(derivedDerivedType); } } }
public static IEnumerable <EntityTypeConfiguration> DerivedTypes(this ODataModelBuilder modelBuilder, EntityTypeConfiguration entity) { if (modelBuilder == null) { throw Error.ArgumentNull("modelBuilder"); } if (entity == null) { throw Error.ArgumentNull("entity"); } IEnumerable <EntityTypeConfiguration> derivedEntities = modelBuilder.StructuralTypes .OfType <EntityTypeConfiguration>().Where(e => e.BaseType == entity); foreach (EntityTypeConfiguration derivedType in derivedEntities) { yield return(derivedType); foreach (EntityTypeConfiguration derivedDerivedType in modelBuilder.DerivedTypes(derivedType)) { yield return(derivedDerivedType); } } }
// Returns the base types, this type and all the derived types of this type. public static IEnumerable <StructuralTypeConfiguration> ThisAndBaseAndDerivedTypes( this ODataModelBuilder modelBuilder, StructuralTypeConfiguration structuralType) { Contract.Assert(modelBuilder != null); Contract.Assert(structuralType != null); return(structuralType.BaseTypes() .Concat(new[] { structuralType }) .Concat(modelBuilder.DerivedTypes(structuralType))); }
private static void FindAllNavigationPropertiesRecursive(this ODataModelBuilder builder, StructuralTypeConfiguration configuration, IList <Tuple <StructuralTypeConfiguration, IList <MemberInfo>, NavigationPropertyConfiguration> > navigations, Stack <MemberInfo> path, HashSet <Type> typesAlreadyProcessed) { if (builder == null) { throw Error.ArgumentNull("builder"); } if (configuration == null) { throw Error.ArgumentNull("configuration"); } if (navigations == null) { throw Error.ArgumentNull("navigations"); } if (path == null) { throw Error.ArgumentNull("path"); } IEnumerable <StructuralTypeConfiguration> thisAndBaseTypes = configuration.ThisAndBaseTypes(); foreach (var config in thisAndBaseTypes) { builder.FindNavigationProperties(config, navigations, path, typesAlreadyProcessed); } IEnumerable <StructuralTypeConfiguration> derivedTypes = builder.DerivedTypes(configuration); foreach (var config in derivedTypes) { if (path.OfType <Type>().Any(p => p == config.ClrType)) { continue; } path.Push(TypeHelper.AsMemberInfo(config.ClrType)); builder.FindNavigationProperties(config, navigations, path, typesAlreadyProcessed); path.Pop(); } }