1

A 有以下类:

public class Parent  
{    
  ...    
  public virtual property IList<ParentParam> Parameters { get; set; } 
}

public class ParentParam { ... }

public class Child: Parent {
  public new virtual property IList<ChildParam> Parameters { get; set; }
}

public class ChildParam : ParentParam { ... }

如何映射子类,以便返回的参数是正确的类型?我尝试简单地映射属性,但它不起作用。

public class ParentMap: ClassMap<Parent>
{
    public ParentMap()
    {
        ...
        HasMany(x => x.Parameters).Cascade.All();
    }
}

public class ChildMap: SubclassMap<Child>
{
    public ChildMap()
    {
        ...
        HasMany(x => x.Parameters).Cascade.All();
    }
}
4

0 回答 0