Question: I am having trouble down-converting a class to it's base interface. I have the following (simplified):

```
public interface ITaxonomy
{
    string CommonName { get; set; }
    string ScientificName { get; set; }
}

public interface ITaxonomyHasChildren<TChild> : ITaxonomy where TChild : ITaxonomy
{
    ICollection<TChild> Children { get; set; }
}

public interface ITaxonomyHasParent<TParent> : ITaxonomy where TParent : ITaxonomy
{
    TParent Parent { get; set; }
}

```

And I need to extract the data back out in my VM:

```
private void SelectedEntityChanged(ITaxonomy selectedEntity)
{
    CommonName = selectedEntity.CommonName;
    ScientificName = selectedEntity.ScientificName;

    Children = selectedEntity.GetType().GetProperty(nameof(ITaxonomyHasChildren<ITaxonomy>.Children))?
        .GetValue(selectedEntity) as ICollection<ITaxonomy>;

    Parent = selectedEntity.GetType().GetProperty(nameof(ITaxonomyHasParent<ITaxonomy>.Parent))?
        .GetValue(selectedEntity) as ITaxonomy;
}

```

The `Children` part doesn't work, I am assuming because it doesn't like converting from `ICollection<MyClass>` to `ICollection<ITaxonomy>`

How can I accomplish this?

Answer: 
In order to make it work, you need to make your generic interfaces [covariant](https://msdn.microsoft.com/en-us/library/mt654058.aspx). But since `ICollection<T>` is not covariant, it would require also changing the `Children` type to `IReadOnlyCollection<TChild>` and remove the setters if you can afford that.

```
public interface ITaxonomyHasChildren<out TChild> : ITaxonomy where TChild : ITaxonomy
{
    IReadOnlyCollection<TChild> Children { get; }
}

public interface ITaxonomyHasParent<out TParent> : ITaxonomy where TParent : ITaxonomy
{
    TParent Parent { get; }
}

```

This will also allow you to avoid reflection:

```
private void SelectedEntityChanged(ITaxonomy selectedEntity)
{
    CommonName = selectedEntity.CommonName;
    ScientificName = selectedEntity.ScientificName;

    Children = (selectedEntity as ITaxonomyHasChildren<ITaxonomy>)?.Children;
    Parent = (selectedEntity as ITaxonomyHasParent<ITaxonomy>)?.Parent;
}

```

A sample class implementation:

```
class Taxonomy : ITaxonomy, ITaxonomyHasChildren<Taxonomy>, ITaxonomyHasParent<Taxonomy>
{
    public string CommonName { get; set; }
    public string ScientificName { get; set; }
    public Taxonomy Parent { get; set; }
    public List<Taxonomy> Children { get; set; } = new List<Taxonomy>();
    IReadOnlyCollection<Taxonomy> ITaxonomyHasChildren<Taxonomy>.Children => Children;
}

```
Invoking 

```
selectedEntity.GetType()
     .GetProperty( nameof(ITaxonomyHasChildren<ITaxonomy>.Children) )
     .GetValue( selectedEntity )

```

is an extremely roundabout way of doing things. 

You should not need to use the reflection system to accomplish basic object oriented stuff.

Also, your types are extremely complicated for no good reason. 

Consider this instead:

```
public interface IParent<T> //note: general-purpose interface unrelated to taxonomies
{
    ICollection<T> Children { get; }
}

public interface IChild<T> //note: general-purpose interface unrelated to taxonomies
{
    T Parent { get; set; }
}

public interface ITaxonomy
{
    string CommonName { get; set; }
    string ScientificName { get; set; }
    IParent<ITaxonomy> AsParent {get; } //returns `null` if not a parent
    IChild<ITaxonomy> AsChild {get; } //returns `null` if not a child
}

IChild<ITaxonomy> selectedEntityAsChild = selectedEntity.AsChild;
if( selectedEntityAsChild != null )
{
    ITaxonomy parent = selectedEntityAsChild.Parent;
    ...
}

IParent<ITaxonomy> selectedEntityAsParent = selectedEntity.AsParent;
if( selectedEntityAsParent != null )
{
    ICollection<ITaxonomy> children = selectedEntityAsParent.Children;
    ...
}

```