Example #1
0
        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);
                }
            }
        }
Example #2
0
        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);
                }
            }
        }
Example #3
0
        // 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)));
        }
Example #4
0
        public static void FindAllNavigationProperties(this ODataModelBuilder builder,
                                                       StructuralTypeConfiguration configuration,
                                                       IList <Tuple <StructuralTypeConfiguration, IList <object>, NavigationPropertyConfiguration> > navigations,
                                                       Stack <object> path)
        {
            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);
            }

            IEnumerable <StructuralTypeConfiguration> derivedTypes = builder.DerivedTypes(configuration);

            foreach (var config in derivedTypes)
            {
                path.Push(config.ClrType);

                builder.FindNavigationProperties(config, navigations, path);

                path.Pop();
            }
        }