protected internal override IEnumerable GetDetailsForParentItem(DataGridCollectionViewBase parentCollectionView, object parentItem)
        {
            EntityObject entityObject = parentItem as EntityObject;

            if (entityObject == null)
            {
                return(null);
            }

            // Even if EntityObject is not in a loadable state, we must still return the IList
            // so that the ItemProperties can be extracted based on the elements type.
            bool entityObjectLoadable = ItemsSourceHelper.IsEntityObjectLoadable(entityObject);

            // We let the user take charge of handling the details.
            QueryEntityDetailsEventArgs args = new QueryEntityDetailsEventArgs(entityObject);

            if (entityObjectLoadable)
            {
                this.OnQueryDetails(args);
            }

            // The parentItem must implement IEntityWithRelationships
            Type parentItemType = parentItem.GetType();

            if (typeof(IEntityWithRelationships).IsAssignableFrom(parentItemType))
            {
                // Since the relationship was based on the the property
                // name, we must find that property using reflection.
                PropertyInfo propertyInfo = parentItemType.GetProperty(this.RelationName);

                if (propertyInfo != null)
                {
                    RelatedEnd relatedEnd = propertyInfo.GetValue(parentItem, null) as RelatedEnd;

                    if (relatedEnd != null)
                    {
                        // Make sure that the details are loaded
                        // except if the user already handled it.
                        if (!relatedEnd.IsLoaded &&
                            !args.Handled &&
                            entityObjectLoadable)
                        {
                            relatedEnd.Load();
                        }

                        IListSource listSource = relatedEnd as IListSource;

                        // Returns an IList to have proper change notification events.
                        if (listSource != null)
                        {
                            return(listSource.GetList());
                        }
                    }
                }
            }

            return(null);
        }