Ejemplo n.º 1
0
            public override void Handle(ExpandedNavigationSelectItem item)
            {
                var navigationSegment = (NavigationPropertySegment)item.PathToNavigationProperty.LastSegment;

                if (navigationSegment.NavigationProperty.DeclaringType == _edmStructuredType)
                {
                    NavigationProperties.Add(navigationSegment.NavigationProperty);
                }
                else
                {
                    Handle(item.SelectAndExpand);
                }
            }
Ejemplo n.º 2
0
            public override void Handle(ExpandedNavigationSelectItem item)
            {
                var navigationSegment = (NavigationPropertySegment)item.PathToNavigationProperty.LastSegment;

                if (IsPropertyDefineInType(navigationSegment.NavigationProperty))
                {
                    NavigationProperties.Add(navigationSegment.NavigationProperty);
                }
                else
                {
                    Handle(item.SelectAndExpand);
                }
            }
Ejemplo n.º 3
0
        protected virtual Object CreateEntity(ODataResourceBase resource, IReadOnlyList <NavigationInfo> navigationProperties)
        {
            Db.OeEntitySetAdapter entitySetAdapter = TestHelper.FindEntitySetAdapterByTypeName(EntitySetAdapters, resource.TypeName);
            Object entity = CreateEntity(entitySetAdapter.EntityType, resource);
            Dictionary <PropertyInfo, NavigationInfo> propertyInfos = null;

            foreach (NavigationInfo navigationInfo in navigationProperties)
            {
                PropertyInfo clrProperty = entitySetAdapter.EntityType.GetProperty(navigationInfo.Name);
                Object       value       = navigationInfo.Value;

                if ((navigationInfo.Count == null && navigationInfo.NextPageLink == null))
                {
                    if (clrProperty.GetSetMethod() != null)
                    {
                        clrProperty.SetValue(entity, value);
                    }
                }
                else
                {
                    if (value == null && navigationInfo.NextPageLink != null)
                    {
                        if (navigationInfo.IsCollection)
                        {
                            value = CreateCollection(clrProperty.PropertyType);
                        }
                        else
                        {
                            value = Activator.CreateInstance(clrProperty.PropertyType);
                        }
                    }

                    clrProperty.SetValue(entity, value);
                    if (value != null)
                    {
                        NavigationProperties.Add(value, navigationInfo);
                    }

                    if (propertyInfos == null)
                    {
                        propertyInfos = new Dictionary <PropertyInfo, NavigationInfo>(navigationProperties.Count);
                        NavigationInfoEntities.Add(entity, propertyInfos);
                    }
                    propertyInfos.Add(clrProperty, navigationInfo);
                }
            }

            return(entity);
        }
Ejemplo n.º 4
0
        protected Object CreateEntity(ODataResource resource, IReadOnlyList <NavigationProperty> navigationProperties)
        {
            Db.OeEntitySetAdapter entitySetAdapter = EntitySetAdapters.FindByTypeName(resource.TypeName);
            Object entity = OeEdmClrHelper.CreateEntity(entitySetAdapter.EntityType, resource);
            Dictionary <PropertyInfo, ODataResourceSetBase> propertyInfos = null;

            foreach (NavigationProperty navigationProperty in navigationProperties)
            {
                PropertyInfo clrProperty = entitySetAdapter.EntityType.GetProperty(navigationProperty.Name);
                Object       value       = navigationProperty.Value;

                if (navigationProperty.ResourceSet == null || (navigationProperty.ResourceSet.Count == null && navigationProperty.ResourceSet.NextPageLink == null))
                {
                    if (clrProperty.GetSetMethod() != null)
                    {
                        clrProperty.SetValue(entity, value);
                    }
                    continue;
                }

                if (value == null && navigationProperty.ResourceSet.NextPageLink != null)
                {
                    value = CreateCollection(clrProperty.PropertyType);
                }

                clrProperty.SetValue(entity, value);
                if (value is IEnumerable collection)
                {
                    NavigationProperties.Add(collection, navigationProperty.ResourceSet);

                    if (propertyInfos == null)
                    {
                        propertyInfos = new Dictionary <PropertyInfo, ODataResourceSetBase>(navigationProperties.Count);
                        NavigationPropertyEntities.Add(entity, propertyInfos);
                    }
                    propertyInfos.Add(clrProperty, navigationProperty.ResourceSet);
                }
            }

            return(entity);
        }
Ejemplo n.º 5
0
 public override void Handle(PathSelectItem item)
 {
     if (item.SelectedPath.LastSegment is NavigationPropertySegment navigationSegment)
     {
         if (IsPropertyDefineInType(navigationSegment.NavigationProperty) &&
             !NavigationProperties.Contains(navigationSegment.NavigationProperty))
         {
             NavigationProperties.Add(navigationSegment.NavigationProperty);
         }
     }
     else if (item.SelectedPath.LastSegment is PropertySegment propertySegment)
     {
         if (IsPropertyDefineInType(propertySegment.Property))
         {
             StructuralProperties.Add(propertySegment.Property);
         }
     }
     else
     {
         throw new InvalidOperationException(item.SelectedPath.LastSegment.GetType().Name + " not supported");
     }
 }