0

I have the following classes called:

public class Parent
{
     public string Field1;
     public string Field2; 
}

public class Child : Parent
{
    public string Field3;
}

I now have a list of Child objects and I need to pass then into a function that is looking for a Parent class.

What is the best way to convert Child class back to the Parent class (I don't care about field3 at this point)?

I am using NHibernate and when I pass in the child class and try to save it, I get this error:

No persister for: ChildClass

even though the 'Parent' class has a persister.

4

1 回答 1

9

Instances of the child class are instances of the parent class.
You don't need to do anything special.

于 2013-04-23T15:20:29.403 回答