Exemplo n.º 1
0
            private void AddCastPropertiesForNavigationProperty(OdcmClass odcmClass, IEdmProperty property, OdcmProperty odcmProperty)
            {
                var derivedTypes = _edmModel.GetDerivedTypeConstraints(property)?.Distinct(StringComparer.InvariantCultureIgnoreCase);

                if (derivedTypes != null)
                {
                    foreach (var derivedType in derivedTypes)
                    {
                        var odcmDerivedClass = TryResolveType <OdcmClass>(derivedType);

                        var derivedCastProperty = odcmProperty.Clone($"{odcmProperty.Name}As{odcmDerivedClass.Name.First().ToString().ToUpper()}{odcmDerivedClass.Name.Substring(1)}");
                        derivedCastProperty.ParentPropertyType = odcmProperty;
                        derivedCastProperty.Projection.Type    = odcmDerivedClass;
                        odcmProperty.ChildPropertyTypes.Add(derivedCastProperty);
                        odcmClass.Properties.Add(derivedCastProperty);
                        _propertyCapabilitiesCache.Add(derivedCastProperty, OdcmCapability.DefaultPropertyCapabilities);
                    }
                }
            }