首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >微风深伸与传承

微风深伸与传承
EN

Stack Overflow用户
提问于 2014-01-09 15:51:17
回答 1查看 117关注 0票数 1

我遇到了一些微风和膨胀的深属性的麻烦。下面是代码:

代码语言:javascript
复制
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 (抽象)集合,而那些ServiceBase包含联系人。

如果我试着像这样扩展:

代码语言:javascript
复制
http://localhost:61971/breeze/EAINHibernate/Requests?$expand=Services,Services.Contacts

联系永远不会扩大。纵观代码,我发现在ExpandMapInitializeWithCascade方法中使用的NHInitializer.cs包含基类的类型。但是,展开时,集合中对象的类型是具体类型,可以是ServiceTranslation类型,也可以是ServiceModification类型。

在这种情况下我们能做些什么呢?我们能指望一个解决办法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-10 22:57:35

抓得好!是的,这是一个bug,你可以期待修复。

更新

修正了现在的GitHub。Fix将包含在下一个版本中。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21024847

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档