我有一些微风和扩大深度属性的麻烦。这是代码:
public abstract class BaseEntity
{
public virtual Guid? Id { get; set; }
}
public partial class Request : BaseEntity
{
public virtual IList<ServiceBase> Services { get; set; }
public Request()
{
this.Services = new List<ServiceBase>();
}
}
public abstract class ServiceBase : BaseEntity
{
public virtual Guid? RequestId { get; set; }
public virtual Request Request { get; set; }
public virtual IList<Contact> Contacts { get; set; }
public ServiceBase()
{
Contacts = new List<Contact>();
}
}
public class ServiceTranslation : ServiceBase
{
public virtual string MyProp { get; set; }
}
public class ServiceModification : ServiceBase
{
public virtual string MyProp2 { get; set; }
}
public class BaseMapping<T> : ClassMapping<T> where T : BaseEntity
{
public BaseMapping()
{
this.Lazy(true);
//Schema("DEMO");
Id(x => x.Id, map => { map.Generator(Generators.GuidComb); });
}
}
public RequestMap()
{
this.Bag<ServiceBase>(x => x.Services, colmap =>
{
//colmap.Schema("demo");
colmap.Key(x => x.Column("RequestId"));
colmap.Inverse(false);
colmap.Cascade(Cascade.All);
}, map =>
{
map.OneToMany();
});
}
}
public ServicebaseMap()
{
this.Property(x => x.RequestId, map =>
{
map.Column("RequestId");
map.Insert(false);
map.Update(false);
map.NotNullable(true);
});
this.ManyToOne(x => x.Request, map =>
{
map.Column("RequestId");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
this.Bag<Contact>(x => x.Contacts, colmap =>
{
//colmap.Schema("demo");
colmap.Table("ServiceContact");
colmap.Key(x => { x.Column("ContactId"); });
colmap.Inverse(false);
colmap.Cascade(Cascade.All);
}, map =>
{
map.ManyToMany(x => { x.Column("ServiceId"); });
});
}
public class ServicetranslationMap : JoinedSubclassMapping<ServiceTranslation>
{
public ServicetranslationMap()
{
Property(x => x.MyProp);
}
}
public class ServiceModificationMap : JoinedSubclassMapping<ServiceModification>
{
public ServiceModificationMap()
{
Property(x => x.MyProp2);
}
}
请求包含ServiceBase(Abstract)的集合,而ServiceBase包含联系人。
如果我尝试像这样扩展:
http://localhost:61971/breeze/EAINHibernate/Requests?$expand=Services,Services.Contacts
从不扩展联系人。通过代码查看,我发现ExpandMap
InitializeWithCascade
方法中{b}使用的NHInitializer.cs
包含基类的类型。但是,在扩展时,集合中对象的类型是具体类型,ServiceTranslation或ServiceModification。
在这种情况下我们能做些什么?我们可以期待修复吗?