Thanks to this article I found the solution.
I created a Type comparer to sort the entity classes based on their
inheritance level, the bases first:
public class OrderTypeByInheritance : IComparer<Type>
{
public int Compare(Type x, Type y)
{
var xClassMapping = x.BaseType.GetGenericArguments().Single();
var yClassMapping = y.BaseType.GetGenericArguments().Single();
return
xClassMapping.InheritanceLevel().CompareTo(yClassMapping.InheritanceLevel());
}
}
public static class TypeExtensions
{
public static int InheritanceLevel(this Type type)
{
var count = 0;
while (type != typeof(object))
{
count++;
type = type.BaseType;
}
return count;
}
}
Than I used it with the ModelMapper:
var mapper = new ModelMapper();
var types = mappingType.Assembly.GetTypes().OrderBy(x => x, new
OrderTypeByInheritance());
On Tuesday, August 19, 2014 11:43:32 AM UTC+2, Matteo Migliore wrote:
>
> Right, sorry:
> internal class ScheduleMapping : ClassMapping<Schedule> { }
>
> internal class EventMapping : JoinedSubclassMapping<Schedule> { }
>
> internal class EventExtendedMapping : JoinedSubclassMapping<EventExtended>
> { }
>
> ---------
> public abstract class Schedule { }
>
> public class Event : Schedule { }
>
> public class EventExtended : Event { }
>
> Thank you.
>
> On Tuesday, August 19, 2014 11:37:04 AM UTC+2, Oskar Berggren wrote:
>>
>> I don't see any mappings?
>>
>>
>> 2014-08-19 11:28 GMT+02:00 Matteo Migliore <[email protected]>:
>>
>>> Hi!
>>>
>>> I map a class with the JoinedSubClass:
>>> public class Event
>>> {
>>> }
>>>
>>> public class EventExtended : Event //sample name
>>> {
>>> }
>>>
>>> NH give me the exception "Cannot extend unmapped class".
>>>
>>> What's wrong?
>>>
>>> Thank you.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "nhusers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/nhusers.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.